Unverified Commit d7aa66c3 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Remove generated error codes (#97687)

### Why?

Should come up with better solution that does not block PRs with git
conflict

x-ref:
https://vercel.slack.com/archives/C02CDC2ALJH/p1785263902728189?thread_ts=1785263687.502649&cid=C02CDC2ALJH

### How?

- Delete `errors.json`, the error-code SWC plugin, generated WASM, merge
driver, and validation/build tooling.
- Stop attaching error codes to server-rendering digests, redboxes, and
telemetry; native `Error.code` and `Error.name` remain available where
applicable.
- Remove the development-overlay error feedback UI, middleware, and
telemetry event that depended on stable codes.
- Update fixtures, snapshots, and guidance for code-free errors and
numeric-only digests.

<!-- NEXT_JS_LLM -->
parent 43273a1d
...@@ -7,6 +7,3 @@ packages/next/compiled/** -text linguist-vendored ...@@ -7,6 +7,3 @@ packages/next/compiled/** -text linguist-vendored
# Make next/src/build folder indexable for github search # Make next/src/build folder indexable for github search
build/** linguist-generated=false build/** linguist-generated=false
# Custom merge driver for auto-generated errors.json
packages/next/errors.json merge=errors-json
...@@ -7,7 +7,6 @@ target ...@@ -7,7 +7,6 @@ target
packages/next/wasm/@next packages/next/wasm/@next
tarballs/ tarballs/
packages/**/*.tgz packages/**/*.tgz
.errors/
# rust compiler crashes # rust compiler crashes
rustc-ice-*.txt rustc-ice-*.txt
......
...@@ -17,8 +17,6 @@ pnpm-lock.yaml ...@@ -17,8 +17,6 @@ pnpm-lock.yaml
packages/next/src/bundles/webpack/packages/*.runtime.js packages/next/src/bundles/webpack/packages/*.runtime.js
packages/next/src/bundles/webpack/packages/lazy-compilation-*.js packages/next/src/bundles/webpack/packages/lazy-compilation-*.js
packages/next/wasm/@next packages/next/wasm/@next
packages/next/errors.json
.github/actions/next-stats-action/.work .github/actions/next-stats-action/.work
crates/**/tests/**/output* crates/**/tests/**/output*
......
...@@ -18,7 +18,6 @@ members = [ ...@@ -18,7 +18,6 @@ members = [
] ]
exclude = [ exclude = [
"crates/next-error-code-swc-plugin",
"rspack/crates/binding" "rspack/crates/binding"
] ]
......
This diff is collapsed.
[package]
name = "next-error-code-swc-plugin"
version = "0.1.0"
edition = "2024"
[lib]
crate-type = ["cdylib"]
[dependencies]
md5 = "0.7"
rustc-hash = "2.1.0"
serde = "1.0"
serde_json = "1.0"
swc_core = { version = "23.0.*", features = ["ecma_plugin_transform"] }
# `swc-plugin` for Next.js Error Code Transformation
## Overview
This plugin transforms Next.js source code by:
- Rewriting `new Error` or `Error` to include an additional property: `Object.defineProperty(new Error(...), "__NEXT_ERROR_CODE", { value: $code, enumerable: false, configurable: true })`. The `enumerable: false` ensures the error code won't show up in console logs while still being accessible for telemetry. The `configurable: true` ensures the error code can be overwritten, useful for transforming errors.
- This enables anonymous error code reporting for user feedback while keeping the message private.
## Error Code Mapping
- **File Location:** `packages/next/errors.json`
- **Structure:** Append-only, increment-based mapping of error codes to messages.
- **Automation:**
- Running `pnpm build` automatically updates `errors.json` if new errors are introduced.
- **Commit Reminder:** Always commit the updated `errors.json` file to avoid CI failures.
## Build Process Details
- **Two-Pass Build:**
1. **First Pass:**
- Extracts new errors and temporarily stores them in `packages/next/.errors/*.json`.
- In CI, a build with new errors will fail.
2. **Second Pass:**
- Updates `packages/next/errors.json` and reruns the build step to confirm no further new errors.
- Inspired by React's [error mapping mechanism](https://github.com/facebook/react/tree/main/scripts/error-codes).
- **Concurrency Handling:** The two-pass system ensures reliable ordering of inserted error codes during concurrent builds.
## Modifying the Plugin
- **WASM Rebuild Required:**
- After modifying the plugin, rebuild the WASM file via `pnpm build-error-code-plugin` and commit it to the repository.
- **Reason:** Pre-built artifacts simplify the build process (`pnpm build` runs without requiring `cargo`).
- **Testing:** Run `cargo test` inside the `crates/next-error-code-swc-plugin` directory to test the plugin.
#!/usr/bin/env bash
set -eu -o pipefail
echo "Building next-error-code-swc-plugin..." >&2
# assumes this script sits in the root of the plugin directory
plugin_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
repo_root="$(realpath "${plugin_dir}/../..")"
nextjs_dir="$repo_root/packages/next"
if ! [ -d "$nextjs_dir" ]; then
echo "Expected to find next.js directory at '$nextjs_dir'" >&2
echo "(based on computed repository root '$repo_root')" >&2
exit 1
fi
BUILD_TARGET='wasm32-wasip1'
cd "$plugin_dir"
rustup target add "$BUILD_TARGET"
CARGO_PROFILE_RELEASE_STRIP=true CARGO_PROFILE_RELEASE_LTO=true cargo build --target "$BUILD_TARGET" --release
output_file="$nextjs_dir/next_error_code_swc_plugin.wasm"
mv "$plugin_dir/target/$BUILD_TARGET/release/next_error_code_swc_plugin.wasm" "$output_file"
echo "✨ Plugin built successfully 🚀" >&2
echo " (Don't forget to commit the generated .wasm file!)" >&2
echo "$output_file"
This diff is collapsed.
...@@ -99,9 +99,6 @@ ...@@ -99,9 +99,6 @@
"swc-build-wasm": "tsx scripts/build-wasm.cjs", "swc-build-wasm": "tsx scripts/build-wasm.cjs",
"build-turbopack-cli": "cargo build -p turbopack-cli --release", "build-turbopack-cli": "cargo build -p turbopack-cli --release",
"sweep": "tsx scripts/sweep.cjs", "sweep": "tsx scripts/sweep.cjs",
"check-error-codes": "node packages/next/check-error-codes.js",
"update-error-codes": "cd packages/next && pnpm taskr compile check_error_codes",
"build-error-code-plugin": "crates/next-error-code-swc-plugin/build-and-move.sh",
"storybook": "turbo run storybook", "storybook": "turbo run storybook",
"build-storybook": "turbo run build-storybook", "build-storybook": "turbo run build-storybook",
"test-storybook": "turbo run test-storybook", "test-storybook": "turbo run test-storybook",
......
This diff is collapsed.
const os = require('os')
const path = require('path')
const fs = require('fs/promises')
const errorsDir = path.join(__dirname, '.errors')
// This script checks for new error codes in .errors directory and consolidates them into errors.json.
// It will fail if new error codes are found, after consolidating them, to ensure error codes are
// properly reviewed and committed.
async function main() {
// Check if .errors directory exists
try {
await fs.access(errorsDir)
} catch {
process.exit(0)
}
let existingErrors = {}
// Load existing errors.json if it exists
try {
existingErrors = JSON.parse(
await fs.readFile(path.join(__dirname, 'errors.json'), 'utf8')
)
} catch {
// Start fresh if errors.json doesn't exist
}
// Calculate next error code
const nextInitialCode =
Object.keys(existingErrors).length > 0
? Math.max(...Object.keys(existingErrors).map(Number)) + 1
: 1
// Process new error files
const errorFiles = [...(await fs.readdir(errorsDir))].map((file) =>
path.join(errorsDir, file)
)
let newErrorCount = 0
for (const file of errorFiles) {
const { errorMessage } = JSON.parse(await fs.readFile(file, 'utf8'))
// Check if message already exists
const existingCode = Object.entries(existingErrors).find(
([_, msg]) => msg === errorMessage
)?.[0]
if (!existingCode) {
// Only add if message is new
const code = nextInitialCode + newErrorCount
existingErrors[code] = errorMessage
newErrorCount++
}
}
// Write updated errors and cleanup
await fs.writeFile(
path.join(__dirname, 'errors.json'),
JSON.stringify(existingErrors, null, 2) +
// Formatters would add these anyway
os.EOL
)
await fs.rm(errorsDir, { recursive: true, force: true })
process.exit(1)
}
main().catch(console.error)
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -213,7 +213,6 @@ import { inlineStaticEnv } from '../lib/inline-static-env' ...@@ -213,7 +213,6 @@ import { inlineStaticEnv } from '../lib/inline-static-env'
import { populateStaticEnv } from '../lib/static-env' import { populateStaticEnv } from '../lib/static-env'
import { durationToString, hrtimeDurationToString } from './duration-to-string' import { durationToString, hrtimeDurationToString } from './duration-to-string'
import { traceGlobals } from '../trace/shared' import { traceGlobals } from '../trace/shared'
import { extractNextErrorCode } from '../lib/error-telemetry-utils'
import { runAfterProductionCompile } from './after-production-compile' import { runAfterProductionCompile } from './after-production-compile'
import { generatePreviewKeys } from './preview-key-utils' import { generatePreviewKeys } from './preview-key-utils'
import { handleBuildComplete } from './adapter/build-complete' import { handleBuildComplete } from './adapter/build-complete'
...@@ -4730,11 +4729,6 @@ function getBundlerForTelemetry(bundler: Bundler) { ...@@ -4730,11 +4729,6 @@ function getBundlerForTelemetry(bundler: Bundler) {
} }
function getErrorCodeForTelemetry(err: unknown) { function getErrorCodeForTelemetry(err: unknown) {
const code = extractNextErrorCode(err)
if (code != null) {
return code
}
if (err instanceof Error && 'code' in err && typeof err.code === 'string') { if (err instanceof Error && 'code' in err && typeof err.code === 'string') {
return err.code return err.code
} }
......
...@@ -543,7 +543,6 @@ export function processMessage( ...@@ -543,7 +543,6 @@ export function processMessage(
case HMR_MESSAGE_SENT_TO_BROWSER.ERRORS_TO_SHOW_IN_BROWSER: { case HMR_MESSAGE_SENT_TO_BROWSER.ERRORS_TO_SHOW_IN_BROWSER: {
createFromReadableStream<{ createFromReadableStream<{
errors: Error[] errors: Error[]
errorCodes: Map<Error, string>
}>( }>(
new ReadableStream({ new ReadableStream({
start(controller) { start(controller) {
...@@ -553,16 +552,8 @@ export function processMessage( ...@@ -553,16 +552,8 @@ export function processMessage(
}), }),
{ findSourceMapURL } { findSourceMapURL }
).then( ).then(
({ errors, errorCodes }) => { ({ errors }) => {
for (const error of errors) { for (const error of errors) {
const code = errorCodes.get(error)
if (code !== undefined) {
Object.defineProperty(error, '__NEXT_ERROR_CODE', {
value: code,
enumerable: false,
configurable: true,
})
}
// These errors originated on the server and were already logged // These errors originated on the server and were already logged
// there. Mark them so the browser-to-terminal log forwarding // there. Mark them so the browser-to-terminal log forwarding
// doesn't replay them back to the CLI as duplicates. // doesn't replay them back to the CLI as duplicates.
......
...@@ -924,14 +924,6 @@ export async function hydrate(opts?: { beforeRender?: () => Promise<void> }) { ...@@ -924,14 +924,6 @@ export async function hydrate(opts?: { beforeRender?: () => Promise<void> }) {
error.name = initialErr!.name error.name = initialErr!.name
error.stack = initialErr!.stack error.stack = initialErr!.stack
// If present, restore the error code from the original server error.
if (typeof initialErr.__NEXT_ERROR_CODE === 'string') {
Object.defineProperty(error, '__NEXT_ERROR_CODE', {
value: initialErr.__NEXT_ERROR_CODE,
enumerable: false,
configurable: true,
})
}
const errSource = initialErr.source! const errSource = initialErr.source!
// In development, error the navigation API usage in runtime, // In development, error the navigation API usage in runtime,
......
const ERROR_CODE_DELIMITER = '@'
/**
* Augments the digest field of errors thrown in React Server Components (RSC) with an error code.
* Since RSC errors can only be serialized through the digest field, this provides a way to include
* an additional error code that can be extracted client-side via `extractNextErrorCode`.
*
* The error code is appended to the digest string with a semicolon separator, allowing it to be
* parsed out later while preserving the original digest value.
*/
export const createDigestWithErrorCode = (
thrownValue: unknown,
originalDigest: string
): string => {
if (
typeof thrownValue === 'object' &&
thrownValue !== null &&
'__NEXT_ERROR_CODE' in thrownValue
) {
return `${originalDigest}${ERROR_CODE_DELIMITER}${thrownValue.__NEXT_ERROR_CODE}`
}
return originalDigest
}
export const extractNextErrorCode = (error: unknown): string | undefined => {
if (
typeof error === 'object' &&
error !== null &&
'__NEXT_ERROR_CODE' in error &&
typeof error.__NEXT_ERROR_CODE === 'string'
) {
return error.__NEXT_ERROR_CODE
}
if (
typeof error === 'object' &&
error !== null &&
'digest' in error &&
typeof error.digest === 'string'
) {
const segments = error.digest.split(ERROR_CODE_DELIMITER)
const errorCode = segments.find((segment) => segment.startsWith('E'))
return errorCode
}
return undefined
}
...@@ -18,7 +18,6 @@ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [ ...@@ -18,7 +18,6 @@ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [
'[data-info-popover]', '[data-info-popover]',
'[data-nextjs-devtools-panel-overlay]', '[data-nextjs-devtools-panel-overlay]',
'[data-nextjs-devtools-panel-footer]', '[data-nextjs-devtools-panel-footer]',
'[data-nextjs-error-overlay-footer]',
] ]
const Dialog: React.FC<DialogProps> = function Dialog({ const Dialog: React.FC<DialogProps> = function Dialog({
......
import { useState, useCallback } from 'react'
import { ThumbsUp } from '../../../../icons/thumbs/thumbs-up'
import { ThumbsDown } from '../../../../icons/thumbs/thumbs-down'
import { cx } from '../../../../utils/cx'
interface ErrorFeedbackProps {
errorCode: string
className?: string
}
export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
const [votedMap, setVotedMap] = useState<Record<string, boolean>>({})
const voted = votedMap[errorCode]
const hasVoted = voted !== undefined
const disabled = process.env.__NEXT_TELEMETRY_DISABLED
const handleFeedback = useCallback(
async (wasHelpful: boolean) => {
// Optimistically set feedback state without loading/error states to keep implementation simple
setVotedMap((prev) => ({
...prev,
[errorCode]: wasHelpful,
}))
try {
const response = await fetch(
`${process.env.__NEXT_ROUTER_BASEPATH || ''}/__nextjs_error_feedback?${new URLSearchParams(
{
errorCode,
wasHelpful: wasHelpful.toString(),
}
)}`
)
if (!response.ok) {
// Handle non-2xx HTTP responses here if needed
console.error('Failed to record feedback on the server.')
}
} catch (error) {
console.error('Failed to record feedback:', error)
}
},
[errorCode]
)
return (
<div
className={cx('error-feedback', className)}
role="region"
aria-label="Error feedback"
>
{hasVoted ? (
<p className="error-feedback-thanks" role="status" aria-live="polite">
Thanks for your feedback!
</p>
) : (
<>
<p>
<a
href="https://nextjs.org/telemetry#error-feedback"
rel="noopener noreferrer"
target="_blank"
>
Was this helpful?
</a>
</p>
<button
aria-disabled={disabled ? 'true' : undefined}
aria-label="Mark as helpful"
onClick={disabled ? undefined : () => handleFeedback(true)}
className={cx('feedback-button', voted === true && 'voted')}
title={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: undefined
}
type="button"
>
<ThumbsUp aria-hidden="true" />
</button>
<button
aria-disabled={disabled ? 'true' : undefined}
aria-label="Mark as not helpful"
onClick={disabled ? undefined : () => handleFeedback(false)}
className={cx('feedback-button', voted === false && 'voted')}
title={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: undefined
}
type="button"
>
<ThumbsDown
aria-hidden="true"
// Optical alignment
style={{
translate: '1px 1px',
}}
/>
</button>
</>
)}
</div>
)
}
export const styles = `
.error-feedback {
display: flex;
align-items: center;
gap: 8px;
white-space: nowrap;
color: var(--color-gray-900);
}
.error-feedback-thanks {
height: var(--size-24);
display: flex;
align-items: center;
padding-right: 4px; /* To match the 4px inner padding of the thumbs up and down icons */
}
.feedback-button {
background: none;
border: none;
border-radius: var(--rounded-full);
width: var(--size-24);
height: var(--size-24);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
&:focus {
outline: var(--focus-ring);
}
&:hover {
background: var(--color-gray-alpha-100);
}
&:active {
background: var(--color-gray-alpha-200);
}
}
.feedback-button[aria-disabled='true'] {
opacity: 0.7;
cursor: not-allowed;
}
.feedback-button.voted {
background: var(--color-gray-alpha-200);
}
.thumbs-up-icon,
.thumbs-down-icon {
color: var(--color-gray-900);
width: var(--size-16);
height: var(--size-16);
}
`
import { ErrorFeedback } from './error-feedback/error-feedback'
import { styles as feedbackStyles } from './error-feedback/error-feedback'
type ErrorOverlayFooterProps = {
errorCode: string | undefined
}
export function ErrorOverlayFooter({ errorCode }: ErrorOverlayFooterProps) {
return (
<footer data-nextjs-error-overlay-footer className="error-overlay-footer">
{errorCode ? (
<ErrorFeedback className="error-feedback" errorCode={errorCode} />
) : null}
</footer>
)
}
export const styles = `
.error-overlay-footer {
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 8px;
padding: 12px 12px 8px 12px;
}
.error-feedback {
margin-left: auto;
p {
font-size: var(--size-14);
font-weight: 500;
margin: 0;
}
}
${feedbackStyles}
`
...@@ -21,7 +21,6 @@ export const Default: Story = { ...@@ -21,7 +21,6 @@ export const Default: Story = {
}, },
errorType: 'Build Error', errorType: 'Build Error',
errorMessage: 'Failed to compile', errorMessage: 'Failed to compile',
errorCode: 'E001',
versionInfo: { versionInfo: {
installed: '15.0.0', installed: '15.0.0',
staleness: 'fresh', staleness: 'fresh',
...@@ -40,10 +39,3 @@ export const Turbopack: Story = { ...@@ -40,10 +39,3 @@ export const Turbopack: Story = {
isTurbopack: true, isTurbopack: true,
}, },
} }
export const NoErrorCode: Story = {
args: {
...Default.args,
errorCode: undefined,
},
}
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
ErrorOverlayToolbar, ErrorOverlayToolbar,
styles as toolbarStyles, styles as toolbarStyles,
} from '../error-overlay-toolbar/error-overlay-toolbar' } from '../error-overlay-toolbar/error-overlay-toolbar'
import { ErrorOverlayFooter } from '../error-overlay-footer/error-overlay-footer'
import { import {
ErrorMessage, ErrorMessage,
styles as errorMessageStyles, styles as errorMessageStyles,
...@@ -47,7 +46,6 @@ export interface ErrorOverlayLayoutProps extends ErrorBaseProps { ...@@ -47,7 +46,6 @@ export interface ErrorOverlayLayoutProps extends ErrorBaseProps {
canGoNext?: boolean canGoNext?: boolean
onPrevious?: () => void onPrevious?: () => void
onNext?: () => void onNext?: () => void
errorCode?: string
error: ReadyRuntimeError['error'] error: ReadyRuntimeError['error']
debugInfo?: DebugInfo debugInfo?: DebugInfo
isBuildError?: boolean isBuildError?: boolean
...@@ -70,7 +68,6 @@ export function ErrorOverlayLayout({ ...@@ -70,7 +68,6 @@ export function ErrorOverlayLayout({
canGoNext, canGoNext,
onPrevious, onPrevious,
onNext, onNext,
errorCode,
errorCount: _errorCount, errorCount: _errorCount,
error, error,
debugInfo, debugInfo,
...@@ -99,7 +96,6 @@ export function ErrorOverlayLayout({ ...@@ -99,7 +96,6 @@ export function ErrorOverlayLayout({
Boolean(transitionDurationMs) Boolean(transitionDurationMs)
) )
const hasFooter = Boolean(errorCode)
const dialogRef = React.useRef<HTMLDivElement | null>(null) const dialogRef = React.useRef<HTMLDivElement | null>(null)
useFocusTrap(dialogRef, null, rendered) useFocusTrap(dialogRef, null, rendered)
...@@ -132,7 +128,7 @@ export function ErrorOverlayLayout({ ...@@ -132,7 +128,7 @@ export function ErrorOverlayLayout({
versionInfo={versionInfo} versionInfo={versionInfo}
renderTabBar={renderTabBar} renderTabBar={renderTabBar}
/> />
<ErrorOverlayDialog onClose={onClose} data-has-footer={hasFooter}> <ErrorOverlayDialog onClose={onClose}>
<Resizer <Resizer
ref={dialogResizerRef} ref={dialogResizerRef}
measure={!animating} measure={!animating}
...@@ -140,11 +136,7 @@ export function ErrorOverlayLayout({ ...@@ -140,11 +136,7 @@ export function ErrorOverlayLayout({
> >
<DialogContent> <DialogContent>
<ErrorOverlayDialogHeader> <ErrorOverlayDialogHeader>
<div <div className="nextjs__container_errors__error_title">
className="nextjs__container_errors__error_title"
// allow assertion in tests before error rating is implemented
data-nextjs-error-code={errorCode}
>
<div className="nextjs__container_errors__error_title__row"> <div className="nextjs__container_errors__error_title__row">
<span data-nextjs-error-label-group> <span data-nextjs-error-label-group>
<ErrorTypeLabel errorType={errorType} /> <ErrorTypeLabel errorType={errorType} />
...@@ -171,7 +163,6 @@ export function ErrorOverlayLayout({ ...@@ -171,7 +163,6 @@ export function ErrorOverlayLayout({
</DialogContent> </DialogContent>
</Resizer> </Resizer>
</ErrorOverlayDialog> </ErrorOverlayDialog>
{hasFooter && <ErrorOverlayFooter errorCode={errorCode} />}
</div> </div>
</ErrorOverlayOverlay> </ErrorOverlayOverlay>
) )
......
...@@ -6,20 +6,16 @@ import { DocsLinkButton } from './docs-link-button' ...@@ -6,20 +6,16 @@ import { DocsLinkButton } from './docs-link-button'
type ErrorOverlayToolbarProps = { type ErrorOverlayToolbarProps = {
error: Error error: Error
debugInfo: DebugInfo | undefined debugInfo: DebugInfo | undefined
feedbackButton?: React.ReactNode
generateErrorInfo: () => Promise<string> generateErrorInfo: () => Promise<string>
} }
export function ErrorOverlayToolbar({ export function ErrorOverlayToolbar({
error, error,
debugInfo, debugInfo,
feedbackButton,
generateErrorInfo, generateErrorInfo,
}: ErrorOverlayToolbarProps) { }: ErrorOverlayToolbarProps) {
return ( return (
<span className="error-overlay-toolbar"> <span className="error-overlay-toolbar">
{/* TODO: Move the button inside and remove the feedback on the footer of the error overlay. */}
{feedbackButton}
<CopyErrorButton error={error} generateErrorInfo={generateErrorInfo} /> <CopyErrorButton error={error} generateErrorInfo={generateErrorInfo} />
<DocsLinkButton errorMessage={error.message} /> <DocsLinkButton errorMessage={error.message} />
<NodejsInspectorButton <NodejsInspectorButton
......
...@@ -679,7 +679,6 @@ export function Errors({ ...@@ -679,7 +679,6 @@ export function Errors({
const { const {
isLoading, isLoading,
errorCode,
errorType, errorType,
activeIdx, activeIdx,
errorDetails, errorDetails,
...@@ -890,7 +889,6 @@ export function Errors({ ...@@ -890,7 +889,6 @@ export function Errors({
} }
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={errorMessage} errorMessage={errorMessage}
headerChildren={ headerChildren={
...@@ -938,7 +936,6 @@ export function Errors({ ...@@ -938,7 +936,6 @@ export function Errors({
case 'client-hook': case 'client-hook':
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={ errorMessage={
<> <>
...@@ -1015,7 +1012,6 @@ export function Errors({ ...@@ -1015,7 +1012,6 @@ export function Errors({
} }
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={errorMessage} errorMessage={errorMessage}
headerChildren={ headerChildren={
...@@ -1092,7 +1088,6 @@ export function Errors({ ...@@ -1092,7 +1088,6 @@ export function Errors({
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={errorMessage} errorMessage={errorMessage}
headerChildren={ headerChildren={
...@@ -1133,7 +1128,6 @@ export function Errors({ ...@@ -1133,7 +1128,6 @@ export function Errors({
case 'sync-io': case 'sync-io':
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={ errorMessage={
<> <>
...@@ -1179,7 +1173,6 @@ export function Errors({ ...@@ -1179,7 +1173,6 @@ export function Errors({
case 'sync-io-client': case 'sync-io-client':
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={ errorMessage={
<> <>
...@@ -1225,7 +1218,6 @@ export function Errors({ ...@@ -1225,7 +1218,6 @@ export function Errors({
case 'unrendered-segment': case 'unrendered-segment':
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage="Next.js could not validate that a segment in your UI has instant navigation." errorMessage="Next.js could not validate that a segment in your UI has instant navigation."
headerChildren={ headerChildren={
...@@ -1260,7 +1252,6 @@ export function Errors({ ...@@ -1260,7 +1252,6 @@ export function Errors({
case 'link-prefetch-partial': case 'link-prefetch-partial':
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage="Next.js encountered dynamic data during prefetching." errorMessage="Next.js encountered dynamic data during prefetching."
headerChildren={ headerChildren={
...@@ -1303,7 +1294,6 @@ export function Errors({ ...@@ -1303,7 +1294,6 @@ export function Errors({
return ( return (
<ErrorOverlayLayout <ErrorOverlayLayout
errorCode={errorCode}
errorType={errorType} errorType={errorType}
errorMessage={errorMessage} errorMessage={errorMessage}
renderTabBar={renderTabBar} renderTabBar={renderTabBar}
......
...@@ -3,7 +3,6 @@ import type { HydrationErrorState } from '../../shared/hydration-error' ...@@ -3,7 +3,6 @@ import type { HydrationErrorState } from '../../shared/hydration-error'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { getErrorTypeLabel, useErrorDetails } from '../container/errors' import { getErrorTypeLabel, useErrorDetails } from '../container/errors'
import { extractNextErrorCode } from '../../../lib/error-telemetry-utils'
export function useActiveRuntimeError({ export function useActiveRuntimeError({
runtimeErrors, runtimeErrors,
...@@ -42,13 +41,11 @@ export function useActiveRuntimeError({ ...@@ -42,13 +41,11 @@ export function useActiveRuntimeError({
setActiveIndex, setActiveIndex,
activeError: null, activeError: null,
errorDetails: null, errorDetails: null,
errorCode: null,
errorType: null, errorType: null,
} }
} }
const error = activeError.error const error = activeError.error
const errorCode = extractNextErrorCode(error)
const errorType = getErrorTypeLabel(error, activeError.type, errorDetails) const errorType = getErrorTypeLabel(error, activeError.type, errorDetails)
return { return {
...@@ -57,7 +54,6 @@ export function useActiveRuntimeError({ ...@@ -57,7 +54,6 @@ export function useActiveRuntimeError({
setActiveIndex, setActiveIndex,
activeError, activeError,
errorDetails, errorDetails,
errorCode,
errorType, errorType,
} }
} }
import type { ComponentProps } from 'react'
export function ThumbsDown(props: ComponentProps<'svg'>) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="thumbs-down-icon"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M5.89531 12.7603C5.72984 12.8785 5.5 12.7602 5.5 12.5569V9.75C5.5 8.7835 4.7165 8 3.75 8H1.5V1.5H11.1884C11.762 1.5 12.262 1.89037 12.4011 2.44683L13.4011 6.44683C13.5984 7.23576 13.0017 8 12.1884 8H8.25H7.5V8.75V11.4854C7.5 11.5662 7.46101 11.6419 7.39531 11.6889L5.89531 12.7603ZM4 12.5569C4 13.9803 5.6089 14.8082 6.76717 13.9809L8.26717 12.9095C8.72706 12.581 9 12.0506 9 11.4854V9.5H12.1884C13.9775 9.5 15.2903 7.81868 14.8563 6.08303L13.8563 2.08303C13.5503 0.858816 12.4503 0 11.1884 0H0.75H0V0.75V8.75V9.5H0.75H3.75C3.88807 9.5 4 9.61193 4 9.75V12.5569Z"
fill="currentColor"
/>
</svg>
)
}
import type { ComponentProps } from 'react'
export function ThumbsUp(props: ComponentProps<'svg'>) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="thumbs-up-icon"
{...props}
>
<g id="thumb-up-16">
<path
id="Union"
fillRule="evenodd"
clipRule="evenodd"
d="M6.89531 2.23959C6.72984 2.1214 6.5 2.23968 6.5 2.44303V5.24989C6.5 6.21639 5.7165 6.99989 4.75 6.99989H2.5V13.4999H12.1884C12.762 13.4999 13.262 13.1095 13.4011 12.5531L14.4011 8.55306C14.5984 7.76412 14.0017 6.99989 13.1884 6.99989H9.25H8.5V6.24989V3.51446C8.5 3.43372 8.46101 3.35795 8.39531 3.31102L6.89531 2.23959ZM5 2.44303C5 1.01963 6.6089 0.191656 7.76717 1.01899L9.26717 2.09042C9.72706 2.41892 10 2.94929 10 3.51446V5.49989H13.1884C14.9775 5.49989 16.2903 7.18121 15.8563 8.91686L14.8563 12.9169C14.5503 14.1411 13.4503 14.9999 12.1884 14.9999H1.75H1V14.2499V6.24989V5.49989H1.75H4.75C4.88807 5.49989 5 5.38796 5 5.24989V2.44303Z"
fill="currentColor"
/>
</g>
</svg>
)
}
...@@ -3,7 +3,6 @@ import { styles as dialog } from '../components/dialog' ...@@ -3,7 +3,6 @@ import { styles as dialog } from '../components/dialog'
import { styles as errorLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { styles as errorLayout } from '../components/errors/error-overlay-layout/error-overlay-layout'
import { styles as pagination } from '../components/errors/error-overlay-pagination/error-overlay-pagination' import { styles as pagination } from '../components/errors/error-overlay-pagination/error-overlay-pagination'
import { styles as overlay } from '../components/overlay/styles' import { styles as overlay } from '../components/overlay/styles'
import { styles as footer } from '../components/errors/error-overlay-footer/error-overlay-footer'
import { TERMINAL_STYLES } from '../components/terminal/terminal' import { TERMINAL_STYLES } from '../components/terminal/terminal'
import { styles as versionStaleness } from '../components/version-staleness-info/version-staleness-info' import { styles as versionStaleness } from '../components/version-staleness-info/version-staleness-info'
import { styles as buildErrorStyles } from '../container/build-error' import { styles as buildErrorStyles } from '../container/build-error'
...@@ -31,7 +30,6 @@ export function ComponentStyles() { ...@@ -31,7 +30,6 @@ export function ComponentStyles() {
${overlay} ${overlay}
${dialog} ${dialog}
${errorLayout} ${errorLayout}
${footer}
${pagination} ${pagination}
${CODE_FRAME_STYLES} ${CODE_FRAME_STYLES}
${TERMINAL_STYLES} ${TERMINAL_STYLES}
......
import { getNextErrorFeedbackMiddleware } from './get-next-error-feedback-middleware'
import type { IncomingMessage, ServerResponse } from 'http'
describe('getNextErrorFeedbackMiddleware', () => {
const mockTelemetry = {
record: jest.fn().mockResolvedValue({}),
} as any
let mockReq: Partial<IncomingMessage>
let mockRes: Partial<ServerResponse>
let mockNext: jest.Mock
beforeEach(() => {
mockReq = {
url: '/__nextjs_error_feedback?errorCode=TEST_ERROR&wasHelpful=true',
}
mockRes = {
setHeader: jest.fn(),
end: jest.fn(),
}
mockNext = jest.fn()
jest.clearAllMocks()
})
it('calls next() if path does not match', async () => {
mockReq.url = '/some-other-path'
await getNextErrorFeedbackMiddleware(mockTelemetry)(
mockReq as IncomingMessage,
mockRes as ServerResponse,
mockNext
)
expect(mockNext).toHaveBeenCalled()
expect(mockTelemetry.record).not.toHaveBeenCalled()
})
it('records telemetry when feedback is submitted', async () => {
await getNextErrorFeedbackMiddleware(mockTelemetry)(
mockReq as IncomingMessage,
mockRes as ServerResponse,
mockNext
)
expect(mockTelemetry.record).toHaveBeenCalledWith({
eventName: 'NEXT_ERROR_FEEDBACK',
payload: {
errorCode: 'TEST_ERROR',
wasHelpful: true,
},
})
expect(mockRes.statusCode).toBe(204)
})
it('returns 400 if params are missing', async () => {
mockReq.url = '/__nextjs_error_feedback'
await getNextErrorFeedbackMiddleware(mockTelemetry)(
mockReq as IncomingMessage,
mockRes as ServerResponse,
mockNext
)
expect(mockRes.statusCode).toBe(400)
expect(mockTelemetry.record).not.toHaveBeenCalled()
})
it('returns 500 if telemetry recording fails', async () => {
mockTelemetry.record.mockRejectedValueOnce(new Error('Failed to record'))
await getNextErrorFeedbackMiddleware(mockTelemetry)(
mockReq as IncomingMessage,
mockRes as ServerResponse,
mockNext
)
expect(mockRes.statusCode).toBe(500)
})
})
import { eventErrorFeedback } from '../../telemetry/events/error-feedback'
import { middlewareResponse } from './middleware-response'
import type { ServerResponse, IncomingMessage } from 'http'
import type { Telemetry } from '../../telemetry/storage'
// Handles HTTP requests to /__nextjs_error_feedback endpoint for collecting user feedback on error messages
export function getNextErrorFeedbackMiddleware(telemetry: Telemetry) {
return async function (
req: IncomingMessage,
res: ServerResponse,
next: () => void
): Promise<void> {
const { pathname, searchParams } = new URL(`http://n${req.url}`)
if (pathname !== '/__nextjs_error_feedback') {
return next()
}
try {
const errorCode = searchParams.get('errorCode')
const wasHelpful = searchParams.get('wasHelpful')
if (!errorCode || !wasHelpful) {
return middlewareResponse.badRequest(res)
}
await telemetry.record(
eventErrorFeedback({
errorCode,
wasHelpful: wasHelpful === 'true',
})
)
return middlewareResponse.noContent(res)
} catch (error) {
return middlewareResponse.internalServerError(res)
}
}
}
...@@ -177,7 +177,6 @@ import { ...@@ -177,7 +177,6 @@ import {
isStaticGenBailoutError, isStaticGenBailoutError,
} from '../../client/components/static-generation-bailout' } from '../../client/components/static-generation-bailout'
import { getStackWithoutErrorMessage } from '../../lib/format-server-error' import { getStackWithoutErrorMessage } from '../../lib/format-server-error'
import { extractNextErrorCode } from '../../lib/error-telemetry-utils'
import { import {
accessedDynamicData, accessedDynamicData,
createRenderInBrowserAbortSignal, createRenderInBrowserAbortSignal,
...@@ -6382,32 +6381,20 @@ async function logMessagesAndSendErrorsToBrowser( ...@@ -6382,32 +6381,20 @@ async function logMessagesAndSendErrorsToBrowser(
) )
} }
// Build a Map of error → error code for errors that have one.
// React doesn't revive __NEXT_ERROR_CODE during RSC deserialization, so we
// send it as a side-channel Map. RSC preserves object identity, so the
// deserialized Map keys will reference the same Error objects.
const errorCodes = new Map<Error, string>()
for (const err of errors) {
const code = extractNextErrorCode(err)
if (code !== undefined) {
errorCodes.set(err, code)
}
}
const { clientModules } = getClientReferenceManifest() const { clientModules } = getClientReferenceManifest()
let errorsFlightStream: AnyStream let errorsFlightStream: AnyStream
if (process.env.__NEXT_USE_NODE_STREAMS) { if (process.env.__NEXT_USE_NODE_STREAMS) {
errorsFlightStream = renderToNodeFlightStream( errorsFlightStream = renderToNodeFlightStream(
ctx.componentMod, ctx.componentMod,
{ errors, errorCodes }, { errors },
clientModules, clientModules,
{ filterStackFrame } { filterStackFrame }
) )
} else { } else {
errorsFlightStream = renderToWebFlightStream( errorsFlightStream = renderToWebFlightStream(
ctx.componentMod, ctx.componentMod,
{ errors, errorCodes }, { errors },
clientModules, clientModules,
{ filterStackFrame } { filterStackFrame }
) )
......
...@@ -10,7 +10,6 @@ import { isDynamicServerError } from '../../client/components/hooks-server-conte ...@@ -10,7 +10,6 @@ import { isDynamicServerError } from '../../client/components/hooks-server-conte
import { isNextRouterError } from '../../client/components/is-next-router-error' import { isNextRouterError } from '../../client/components/is-next-router-error'
import { isPrerenderInterruptedError } from './dynamic-rendering' import { isPrerenderInterruptedError } from './dynamic-rendering'
import { getProperError } from '../../lib/is-error' import { getProperError } from '../../lib/is-error'
import { createDigestWithErrorCode } from '../../lib/error-telemetry-utils'
import { isReactLargeShellError } from './react-large-shell-error' import { isReactLargeShellError } from './react-large-shell-error'
import { isInstantValidationError } from './instant-validation/instant-validation-error' import { isInstantValidationError } from './instant-validation/instant-validation-error'
...@@ -106,10 +105,7 @@ export function createReactServerErrorHandler( ...@@ -106,10 +105,7 @@ export function createReactServerErrorHandler(
err.digest = err.digest =
typeof thrownValue === 'string' typeof thrownValue === 'string'
? stringHash(thrownValue).toString() ? stringHash(thrownValue).toString()
: createDigestWithErrorCode( : stringHash(err.message + (err.stack || '')).toString()
err,
stringHash(err.message + (err.stack || '')).toString()
)
} }
// @TODO by putting this here and not at the top it is possible that // @TODO by putting this here and not at the top it is possible that
...@@ -193,12 +189,9 @@ export function createHTMLErrorHandler( ...@@ -193,12 +189,9 @@ export function createHTMLErrorHandler(
// from other means so we don't need to produce a new one // from other means so we don't need to produce a new one
} }
} else { } else {
err.digest = createDigestWithErrorCode( err.digest = stringHash(
err, err.message + (errorInfo?.componentStack || err.stack || '')
stringHash( ).toString()
err.message + (errorInfo?.componentStack || err.stack || '')
).toString()
)
} }
// Format server errors in development to add more helpful error messages // Format server errors in development to add more helpful error messages
......
import type { AppPageModule } from '../route-modules/app-page/module' import type { AppPageModule } from '../route-modules/app-page/module'
import { renderToNodeFlightStream } from './stream-ops' import { renderToNodeFlightStream } from './stream-ops'
import { getClientReferenceManifest } from './manifests-singleton' import { getClientReferenceManifest } from './manifests-singleton'
import { extractNextErrorCode } from '../../lib/error-telemetry-utils'
const filterStackFrame = const filterStackFrame =
process.env.NODE_ENV !== 'production' process.env.NODE_ENV !== 'production'
...@@ -14,28 +13,17 @@ const filterStackFrame = ...@@ -14,28 +13,17 @@ const filterStackFrame =
* revives. Must run in the runtime that produced the errors (the in-process * revives. Must run in the runtime that produced the errors (the in-process
* render or the validation worker) so the encode uses the matching * render or the validation worker) so the encode uses the matching
* client-reference manifest and captures the live `Error` objects with their * client-reference manifest and captures the live `Error` objects with their
* stacks and digests. The error codes ride along in a side-channel `Map` * stacks and digests.
* because React doesn't revive `__NEXT_ERROR_CODE` during RSC deserialization;
* RSC preserves object identity, so the revived map keys reference the same
* errors.
*/ */
export async function serializeValidationErrorsToFlight( export async function serializeValidationErrorsToFlight(
componentMod: AppPageModule, componentMod: AppPageModule,
errors: Error[] errors: Error[]
): Promise<Uint8Array[]> { ): Promise<Uint8Array[]> {
const errorCodes = new Map<Error, string>()
for (const err of errors) {
const code = extractNextErrorCode(err)
if (code !== undefined) {
errorCodes.set(err, code)
}
}
const { clientModules } = getClientReferenceManifest() const { clientModules } = getClientReferenceManifest()
const stream = renderToNodeFlightStream( const stream = renderToNodeFlightStream(
componentMod, componentMod,
{ errors, errorCodes }, { errors },
clientModules, clientModules,
{ filterStackFrame } { filterStackFrame }
) )
......
...@@ -133,7 +133,7 @@ export type DevValidationWorkerMessage = DevValidationSnapshot & ...@@ -133,7 +133,7 @@ export type DevValidationWorkerMessage = DevValidationSnapshot &
DevValidationInstallFields DevValidationInstallFields
/** /**
* The RSC-encoded `{ errors, errorCodes }` Flight chunks for the dev overlay, * The RSC-encoded `{ errors }` Flight chunks for the dev overlay,
* or null when validation produced no errors or was aborted. The worker also * or null when validation produced no errors or was aborted. The worker also
* logs the errors to its own stderr (piped to the parent) with code frames. * logs the errors to its own stderr (piped to the parent) with code frames.
*/ */
......
...@@ -1101,9 +1101,6 @@ export function trackDynamicHoleInStaticShell( ...@@ -1101,9 +1101,6 @@ export function trackDynamicHoleInStaticShell(
/** /**
* In dev mode, we prefer using the owner stack, otherwise the provided * In dev mode, we prefer using the owner stack, otherwise the provided
* component stack is used. * component stack is used.
*
* Accepts an already-created Error so the SWC error-code plugin can see the
* `new Error(...)` call at each call site and auto-assign error codes.
*/ */
function addErrorContext( function addErrorContext(
error: Error, error: Error,
......
...@@ -92,7 +92,6 @@ import { isDeferredEntry } from '../../build/entries' ...@@ -92,7 +92,6 @@ import { isDeferredEntry } from '../../build/entries'
import { isMetadataRouteFile } from '../../lib/metadata/is-metadata-route' import { isMetadataRouteFile } from '../../lib/metadata/is-metadata-route'
import { setBundlerFindSourceMapImplementation } from '../patch-error-inspect' import { setBundlerFindSourceMapImplementation } from '../patch-error-inspect'
import { setBundlerFindSourceMapURLImplementation } from '../lib/source-maps' import { setBundlerFindSourceMapURLImplementation } from '../lib/source-maps'
import { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware'
import { import {
formatIssue, formatIssue,
isFileSystemCacheEnabledForDev, isFileSystemCacheEnabledForDev,
...@@ -1148,7 +1147,6 @@ export async function createHotReloaderTurbopack( ...@@ -1148,7 +1147,6 @@ export async function createHotReloaderTurbopack(
isSrcDir: opts.isSrcDir, isSrcDir: opts.isSrcDir,
}), }),
getSourceMapMiddleware(project), getSourceMapMiddleware(project),
getNextErrorFeedbackMiddleware(opts.telemetry),
getDevOverlayFontMiddleware(), getDevOverlayFontMiddleware(),
getDisableDevIndicatorMiddleware(), getDisableDevIndicatorMiddleware(),
getRestartDevServerMiddleware({ getRestartDevServerMiddleware({
......
...@@ -84,7 +84,6 @@ import type { HmrMessageSentToBrowser } from './hot-reloader-types' ...@@ -84,7 +84,6 @@ import type { HmrMessageSentToBrowser } from './hot-reloader-types'
import type { WebpackError } from 'webpack' import type { WebpackError } from 'webpack'
import { PAGE_TYPES } from '../../lib/page-types' import { PAGE_TYPES } from '../../lib/page-types'
import { FAST_REFRESH_RUNTIME_RELOAD } from './messages' import { FAST_REFRESH_RUNTIME_RELOAD } from './messages'
import { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware'
import { getDevOverlayFontMiddleware } from '../../next-devtools/server/font/get-dev-overlay-font-middleware' import { getDevOverlayFontMiddleware } from '../../next-devtools/server/font/get-dev-overlay-font-middleware'
import { getDisableDevIndicatorMiddleware } from '../../next-devtools/server/dev-indicator-middleware' import { getDisableDevIndicatorMiddleware } from '../../next-devtools/server/dev-indicator-middleware'
import getWebpackBundler from '../../shared/lib/get-webpack-bundler' import getWebpackBundler from '../../shared/lib/get-webpack-bundler'
...@@ -1663,7 +1662,6 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface { ...@@ -1663,7 +1662,6 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface {
serverStats: () => this.serverStats, serverStats: () => this.serverStats,
edgeServerStats: () => this.edgeServerStats, edgeServerStats: () => this.edgeServerStats,
}), }),
getNextErrorFeedbackMiddleware(this.telemetry),
getDevOverlayFontMiddleware(), getDevOverlayFontMiddleware(),
getDisableDevIndicatorMiddleware(), getDisableDevIndicatorMiddleware(),
getRestartDevServerMiddleware({ getRestartDevServerMiddleware({
......
...@@ -405,8 +405,7 @@ export default class DevServer extends Server { ...@@ -405,8 +405,7 @@ export default class DevServer extends Server {
request.url.includes('/_next/static') || request.url.includes('/_next/static') ||
request.url.includes('/__nextjs_attach-nodejs-inspector') || request.url.includes('/__nextjs_attach-nodejs-inspector') ||
request.url.includes('/__nextjs_original-stack-frame') || request.url.includes('/__nextjs_original-stack-frame') ||
request.url.includes('/__nextjs_source-map') || request.url.includes('/__nextjs_source-map')
request.url.includes('/__nextjs_error_feedback')
) { ) {
return { finished: false } return { finished: false }
} }
......
...@@ -43,15 +43,6 @@ export function getServerError(error: Error, type: ErrorSourceType): Error { ...@@ -43,15 +43,6 @@ export function getServerError(error: Error, type: ErrorSourceType): Error {
} }
n.name = error.name n.name = error.name
// If present, restore the error code from the original server error.
const errorCode = (error as any).__NEXT_ERROR_CODE
if (typeof errorCode === 'string') {
Object.defineProperty(n, '__NEXT_ERROR_CODE', {
value: errorCode,
enumerable: false,
configurable: true,
})
}
try { try {
n.stack = `${n.toString()}\n${parse(error.stack!) n.stack = `${n.toString()}\n${parse(error.stack!)
.map(getFilesystemFrame) .map(getFilesystemFrame)
......
...@@ -103,7 +103,6 @@ import { RenderSpan } from './lib/trace/constants' ...@@ -103,7 +103,6 @@ import { RenderSpan } from './lib/trace/constants'
import { ReflectAdapter } from './web/spec-extension/adapters/reflect' import { ReflectAdapter } from './web/spec-extension/adapters/reflect'
import { getCacheControlHeader } from './lib/cache-control' import { getCacheControlHeader } from './lib/cache-control'
import { getErrorSource } from '../shared/lib/error-source' import { getErrorSource } from '../shared/lib/error-source'
import { extractNextErrorCode } from '../lib/error-telemetry-utils'
import type { DeepReadonly } from '../shared/lib/deep-readonly' import type { DeepReadonly } from '../shared/lib/deep-readonly'
import type { PagesDevOverlayBridgeType } from '../next-devtools/userspace/pages/pages-dev-overlay-setup' import type { PagesDevOverlayBridgeType } from '../next-devtools/userspace/pages/pages-dev-overlay-setup'
import { getScriptNonceFromHeader } from './app-render/get-script-nonce-from-header' import { getScriptNonceFromHeader } from './app-render/get-script-nonce-from-header'
...@@ -424,7 +423,6 @@ export function errorToJSON(err: Error) { ...@@ -424,7 +423,6 @@ export function errorToJSON(err: Error) {
message: stripAnsi(err.message), message: stripAnsi(err.message),
stack: err.stack, stack: err.stack,
digest: (err as any).digest, digest: (err as any).digest,
__NEXT_ERROR_CODE: extractNextErrorCode(err),
} }
} }
......
...@@ -61,7 +61,6 @@ import { ...@@ -61,7 +61,6 @@ import {
createReactServerErrorHandler, createReactServerErrorHandler,
type DigestedError, type DigestedError,
} from '../app-render/create-error-handler' } from '../app-render/create-error-handler'
import { createDigestWithErrorCode } from '../../lib/error-telemetry-utils'
import stringHash from 'next/dist/compiled/string-hash' import stringHash from 'next/dist/compiled/string-hash'
import { import {
MIN_PRERENDERABLE_EXPIRE, MIN_PRERENDERABLE_EXPIRE,
...@@ -1533,10 +1532,9 @@ async function generateCacheEntryImpl( ...@@ -1533,10 +1532,9 @@ async function generateCacheEntryImpl(
// error actually surfaces (vs. being caught in userland) is // error actually surfaces (vs. being caught in userland) is
// the consumer's decision, so the "surfaced" mark is left to // the consumer's decision, so the "surfaced" mark is left to
// the outer handler. // the outer handler.
const digest = createDigestWithErrorCode( const digest = stringHash(
error, error.message + (error.stack || '')
stringHash(error.message + (error.stack || '')).toString() ).toString()
)
workStore.reactServerErrorsByDigest.set( workStore.reactServerErrorsByDigest.set(
digest, digest,
......
...@@ -12,9 +12,6 @@ export class TurbopackInternalError extends Error { ...@@ -12,9 +12,6 @@ export class TurbopackInternalError extends Error {
name = 'TurbopackInternalError' name = 'TurbopackInternalError'
location: string | undefined location: string | undefined
// Manually set this as this isn't statically determinable
__NEXT_ERROR_CODE = 'TurbopackInternalError'
constructor({ message, anonymizedLocation }: TurbopackInternalErrorOpts) { constructor({ message, anonymizedLocation }: TurbopackInternalErrorOpts) {
super(message) super(message)
this.location = anonymizedLocation this.location = anonymizedLocation
......
...@@ -99,7 +99,6 @@ export type NEXT_DATA = { ...@@ -99,7 +99,6 @@ export type NEXT_DATA = {
err?: Error & { err?: Error & {
statusCode?: number statusCode?: number
source?: typeof COMPILER_NAMES.server | typeof COMPILER_NAMES.edgeServer source?: typeof COMPILER_NAMES.server | typeof COMPILER_NAMES.edgeServer
__NEXT_ERROR_CODE?: string
} }
gsp?: boolean gsp?: boolean
gssp?: boolean gssp?: boolean
......
import type { TelemetryPlugin } from '../../build/webpack/plugins/telemetry-plugin/telemetry-plugin' import type { TelemetryPlugin } from '../../build/webpack/plugins/telemetry-plugin/telemetry-plugin'
import type { SWC_TARGET_TRIPLE } from '../../build/webpack/plugins/telemetry-plugin/telemetry-plugin' import type { SWC_TARGET_TRIPLE } from '../../build/webpack/plugins/telemetry-plugin/telemetry-plugin'
import type { UseCacheTrackerKey } from '../../build/webpack/plugins/telemetry-plugin/use-cache-tracker-utils' import type { UseCacheTrackerKey } from '../../build/webpack/plugins/telemetry-plugin/use-cache-tracker-utils'
import { extractNextErrorCode } from '../../lib/error-telemetry-utils'
const REGEXP_DIRECTORY_DUNDER = const REGEXP_DIRECTORY_DUNDER =
/[\\/]__[^\\/]+(?<![\\/]__(?:tests|mocks))__[\\/]/i /[\\/]__[^\\/]+(?<![\\/]__(?:tests|mocks))__[\\/]/i
...@@ -309,8 +308,8 @@ type ErrorThrownEvent = { ...@@ -309,8 +308,8 @@ type ErrorThrownEvent = {
} }
} }
// Creates a Telemetry event for errors. For privacy, only includes the error code and not the error // Creates a Telemetry event for errors. For privacy, only includes the error name and not the error
// message. // message. The payload field retains its existing name for telemetry schema compatibility.
// //
// `location` may be included if it's a location internal to the next.js source tree (i.e. a // `location` may be included if it's a location internal to the next.js source tree (i.e. a
// non-absolute path). // non-absolute path).
...@@ -321,7 +320,7 @@ export function eventErrorThrown( ...@@ -321,7 +320,7 @@ export function eventErrorThrown(
return { return {
eventName: ERROR_THROWN_EVENT, eventName: ERROR_THROWN_EVENT,
payload: { payload: {
errorCode: extractNextErrorCode(error) || 'Unknown', errorCode: error.name || 'Unknown',
location: anonymizedLocation, location: anonymizedLocation,
}, },
} }
......
export const eventNameErrorFeedback = 'NEXT_ERROR_FEEDBACK'
export type EventErrorFeedback = {
errorCode: string
wasHelpful: boolean
}
/**
* Records telemetry for error feedback.
*
* @example
* ```ts
* telemetry.record(eventErrorFeedback({
* errorCode: 'E1',
* wasHelpful: true
* }))
* ```
*/
export function eventErrorFeedback(event: EventErrorFeedback): {
eventName: string
payload: EventErrorFeedback
} {
return {
eventName: eventNameErrorFeedback,
payload: event,
}
}
...@@ -25,12 +25,6 @@ module.exports = function (task) { ...@@ -25,12 +25,6 @@ module.exports = function (task) {
) )
return return
const plugins = [
...(file.base.includes('.test.') || file.base.includes('.stories.')
? []
: [[path.join(__dirname, 'next_error_code_swc_plugin.wasm'), {}]]),
]
const isClient = serverOrClient === 'client' const isClient = serverOrClient === 'client'
/** @type {import('@swc/core').Options} */ /** @type {import('@swc/core').Options} */
const swcClientOptions = { const swcClientOptions = {
...@@ -57,7 +51,6 @@ module.exports = function (task) { ...@@ -57,7 +51,6 @@ module.exports = function (task) {
}, },
experimental: { experimental: {
keepImportAttributes: esm, keepImportAttributes: esm,
plugins,
}, },
transform: { transform: {
react: { react: {
...@@ -103,7 +96,6 @@ module.exports = function (task) { ...@@ -103,7 +96,6 @@ module.exports = function (task) {
}, },
experimental: { experimental: {
keepImportAttributes: esm, keepImportAttributes: esm,
plugins,
}, },
transform: { transform: {
react: { react: {
......
...@@ -3,7 +3,6 @@ const glob = require('glob') ...@@ -3,7 +3,6 @@ const glob = require('glob')
const fs = require('fs/promises') const fs = require('fs/promises')
const resolveFrom = require('resolve-from') const resolveFrom = require('resolve-from')
const execa = require('execa') const execa = require('execa')
const process = require('process')
const recast = require('recast') const recast = require('recast')
export async function next__polyfill_nomodule(task, opts) { export async function next__polyfill_nomodule(task, opts) {
...@@ -2726,10 +2725,7 @@ export async function diagnostics(task, opts) { ...@@ -2726,10 +2725,7 @@ export async function diagnostics(task, opts) {
} }
export async function build(task, opts) { export async function build(task, opts) {
await task.serial( await task.serial(['precompile', 'compile', 'generate_types'], opts)
['precompile', 'compile', 'check_error_codes', 'generate_types'],
opts
)
} }
export async function generate_types(task, opts) { export async function generate_types(task, opts) {
...@@ -2750,25 +2746,6 @@ export async function generate_types(task, opts) { ...@@ -2750,25 +2746,6 @@ export async function generate_types(task, opts) {
} }
} }
export async function check_error_codes(task, opts) {
try {
await execa.command('pnpm -w run check-error-codes', {
stdio: 'inherit',
})
} catch (err) {
if (process.env.CI) {
await execa.command(
'echo check_error_codes FAILED: There are new errors introduced but no corresponding error codes are found in errors.json file, so make sure you run `pnpm build` or `pnpm update-error-codes` and then commit the change in errors.json.',
{
stdio: 'inherit',
}
)
process.exit(1)
}
await task.start('compile', opts)
}
}
export default async function (task) { export default async function (task) {
const opts = { dev: true } const opts = { dev: true }
await task.clear('dist') await task.clear('dist')
......
...@@ -6,14 +6,3 @@ await execa('git', ['config', 'index.skipHash', 'false'], { ...@@ -6,14 +6,3 @@ await execa('git', ['config', 'index.skipHash', 'false'], {
stdio: 'inherit', stdio: 'inherit',
reject: false, reject: false,
}) })
// Enable the errors.json git merge driver.
// It can be disabled by running:
//
// scripts/merge-errors-json/uninstall
//
// or by manually removing the `[merge "errors-json"]` section from your .git/config.
await execa('scripts/merge-errors-json/install', [], {
stdio: 'inherit',
reject: false,
})
#!/bin/sh
driver_name='errors-json'
git config merge."$driver_name".name 'Automatically merge packages/next/errors.json'
git config merge."$driver_name".driver 'node scripts/merge-errors-json/merge.mjs %A %O %B'
// @ts-check
/**
* Git merge driver for packages/next/errors.json
*
* This script automatically resolves merge conflicts in the auto-generated
* errors.json file by reassigning error codes to avoid conflicts.
*
* Usage: node merge-errors-json.mjs <current> <base> <other> [<marker-size>]
*
* Arguments:
* - current: Path to the current version (our changes)
* - base: Path to the common ancestor version
* - other: Path to the other version (their changes)
* - marker-size: Size of conflict markers (optional, defaults to 7)
*
* Exit codes:
* - 0: Merge successful, result written to current file
* - 1: Merge failed, conflicts remain
*/
import { readFileSync, writeFileSync } from 'node:fs'
function main() {
const args = process.argv.slice(2)
if (args.length < 3) {
console.error(
'Usage: node merge-errors-json.mjs <current> <base> <other> [<marker-size>]'
)
process.exit(1)
}
const [currentPath, basePath, otherPath] = args
try {
const base = readJsonSync(basePath)
const current = readJsonSync(currentPath)
const other = readJsonSync(otherPath)
const merged = mergeErrors(base, current, other)
// Git expects the result to be written to the "current" file
writeJsonSync(currentPath, merged)
const addedCount = Object.keys(merged).length - Object.keys(current).length
console.error(
`merge-errors-json: added ${addedCount === 1 ? '1 new message' : `${addedCount} new messages`} to errors.json`
)
process.exit(0)
} catch (error) {
console.error('merge-errors-json: merge failed:', error.message)
console.error()
console.error(
[
'if this error persists, you can disable the merge driver by running',
'',
' scripts/merge-errors-json/uninstall',
'',
'or by manually removing the `[merge "errors-json"]` section from your .git/config.',
].join('\n')
)
process.exit(1)
}
}
/**
* @typedef {Record<string, string>} ErrorsMap
*/
/**
* Merge three versions of errors.json, resolving conflicts by assigning new sequential IDs
* @param {ErrorsMap} base - Base version (common ancestor)
* @param {ErrorsMap} current - Current version (our changes, or the state of the branch we're rebasing onto)
* @param {ErrorsMap} other - Other version (their changes, or the state the branch we're rebasing, a.k.a. "incoming")
* @returns {ErrorsMap}
*/
function mergeErrors(base, current, other) {
/** @type {ErrorsMap} */
const result = { ...current }
/** @type {Set<string>} */
const existingMessages = new Set(Object.values(result))
let nextKey = getMaxNumericKey(result) + 1
for (const message of getNewMessages(base, other)) {
if (existingMessages.has(message)) {
continue
}
const key = nextKey++
result[key] = message
existingMessages.add(message)
}
return result
}
/**
* Returns the largest numeric key in the map, or 0 if there are no numeric
* keys. Existing entries may have gaps (e.g. when error codes were retired),
* so we can't rely on `Object.keys(result).length` to derive the next id.
* @param {ErrorsMap} map
*/
function getMaxNumericKey(map) {
let max = 0
for (const key of Object.keys(map)) {
const n = Number(key)
if (Number.isInteger(n) && n > max) {
max = n
}
}
return max
}
function getNewMessages(
/** @type {ErrorsMap} */ prev,
/** @type {ErrorsMap} */ current
) {
const existing = new Set(Object.values(prev))
return Object.values(current).filter((msg) => !existing.has(msg))
}
function readJsonSync(/** @type {string} */ filePath) {
const content = readFileSync(filePath, 'utf8')
return JSON.parse(content)
}
function writeJsonSync(
/** @type {string} */ filePath,
/** @type {any} */ value
) {
const content = JSON.stringify(value, null, 2) + '\n'
writeFileSync(filePath, content, 'utf8')
}
main()
#!/bin/sh
driver_name='errors-json'
git config --remove-section merge."$driver_name"
...@@ -146,7 +146,7 @@ After each fix, rerun the scoped build when available, then run `next build` aga ...@@ -146,7 +146,7 @@ After each fix, rerun the scoped build when available, then run `next build` aga
After the build passes, confirm the root layout got an opt-out (`grep -n "export const instant" <app dir>/layout.*`). The root layout renders every route, including framework routes like `/_not-found`, so if it was missed, add `export const instant = false` to it by hand. After the build passes, confirm the root layout got an opt-out (`grep -n "export const instant" <app dir>/layout.*`). The root layout renders every route, including framework routes like `/_not-found`, so if it was missed, add `export const instant = false` to it by hand.
Synthetic routes like `/_not-found` have no user file — when they block, fix the root layout's opt-out, not the synthetic route. Client Components (`"use client"`) get no opt-out (it's a build error — `E1344` — to export `instant` from them), but they are not a rare blocker. The high-frequency case is a client component in the root layout's nav or header calling `usePathname()`/`useSearchParams()`: it blocks _every_ dynamic route with `blocking-prerender-client-hook`, and static routes pass (the pathname is known at prerender), which masks it until you reach a dynamic segment. It's not an ancestor-data fix — follow the [error's docs page](https://nextjs.org/docs/messages/blocking-prerender-client-hook) for the `<Suspense>` recipe. Only when a client route blocks on _server_ data do you fix that data in its ancestor. Synthetic routes like `/_not-found` have no user file — when they block, fix the root layout's opt-out, not the synthetic route. Client Components (`"use client"`) get no opt-out (it's a build error to export `instant` from them), but they are not a rare blocker. The high-frequency case is a client component in the root layout's nav or header calling `usePathname()`/`useSearchParams()`: it blocks _every_ dynamic route with `blocking-prerender-client-hook`, and static routes pass (the pathname is known at prerender), which masks it until you reach a dynamic segment. It's not an ancestor-data fix — follow the [error's docs page](https://nextjs.org/docs/messages/blocking-prerender-client-hook) for the `<Suspense>` recipe. Only when a client route blocks on _server_ data do you fix that data in its ancestor.
### end of the pre-step: check in ### end of the pre-step: check in
......
...@@ -1448,7 +1448,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1448,7 +1448,6 @@ describe('ReactRefreshLogBox app', () => {
if (isRspack) { if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(` await expect({ browser, next }).toDisplayRedbox(`
{ {
"code": "E394",
"description": "module error", "description": "module error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1468,7 +1467,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1468,7 +1467,6 @@ describe('ReactRefreshLogBox app', () => {
} else if (!isTurbopack) { } else if (!isTurbopack) {
await expect({ browser, next }).toDisplayRedbox(` await expect({ browser, next }).toDisplayRedbox(`
{ {
"code": "E394",
"description": "module error", "description": "module error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -137,7 +137,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -137,7 +137,6 @@ describe('Error overlay for hydration errors in App router', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -172,7 +171,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -172,7 +171,6 @@ describe('Error overlay for hydration errors in App router', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -332,7 +330,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -332,7 +330,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -404,7 +401,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -404,7 +401,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -499,7 +495,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -499,7 +495,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -557,7 +552,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -557,7 +552,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -615,7 +609,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -615,7 +609,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -673,7 +666,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -673,7 +666,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -710,7 +702,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -710,7 +702,6 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<p> cannot contain a nested <p>. "description": "<p> cannot contain a nested <p>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -753,7 +744,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -753,7 +744,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.", "description": "Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -765,7 +755,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -765,7 +755,6 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -800,7 +789,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -800,7 +789,6 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<html> cannot contain a nested <script>. "description": "<html> cannot contain a nested <script>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -819,7 +807,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -819,7 +807,6 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.", "description": "Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -831,7 +818,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -831,7 +818,6 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -865,7 +851,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -865,7 +851,6 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<html> cannot contain a nested <script>. "description": "<html> cannot contain a nested <script>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
......
...@@ -53,7 +53,6 @@ describe('Error overlay - RSC runtime errors', () => { ...@@ -53,7 +53,6 @@ describe('Error overlay - RSC runtime errors', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E251",
"description": "\`cookies\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context", "description": "\`cookies\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -19,7 +19,6 @@ describe('ReactRefreshLogBox _app _document', () => { ...@@ -19,7 +19,6 @@ describe('ReactRefreshLogBox _app _document', () => {
const { browser, session } = sandbox const { browser, session } = sandbox
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E464",
"description": "The default export is not a React Component in page: "/_app"", "description": "The default export is not a React Component in page: "/_app"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -49,7 +48,6 @@ describe('ReactRefreshLogBox _app _document', () => { ...@@ -49,7 +48,6 @@ describe('ReactRefreshLogBox _app _document', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E511",
"description": "The default export is not a React Component in page: "/_document"", "description": "The default export is not a React Component in page: "/_document"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -116,7 +116,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -116,7 +116,6 @@ describe('ReactRefreshLogBox', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -134,7 +133,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -134,7 +133,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -159,7 +157,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -159,7 +157,6 @@ describe('ReactRefreshLogBox', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -177,7 +174,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -177,7 +174,6 @@ describe('ReactRefreshLogBox', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -204,7 +200,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -204,7 +200,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1071,7 +1066,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1071,7 +1066,6 @@ describe('ReactRefreshLogBox', () => {
if (isReact18) { if (isReact18) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "{"a":1,"b":"x"}", "description": "{"a":1,"b":"x"}",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1082,7 +1076,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1082,7 +1076,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "{"a":1,"b":"x"}", "description": "{"a":1,"b":"x"}",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1121,7 +1114,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1121,7 +1114,6 @@ describe('ReactRefreshLogBox', () => {
if (isReact18) { if (isReact18) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "class Hello { "description": "class Hello {
}", }",
"environmentLabel": null, "environmentLabel": null,
...@@ -1133,7 +1125,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1133,7 +1125,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "class Hello { "description": "class Hello {
}", }",
"environmentLabel": null, "environmentLabel": null,
...@@ -1171,7 +1162,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1171,7 +1162,6 @@ describe('ReactRefreshLogBox', () => {
if (isReact18) { if (isReact18) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "string error", "description": "string error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1182,7 +1172,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1182,7 +1172,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "string error", "description": "string error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1219,7 +1208,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1219,7 +1208,6 @@ describe('ReactRefreshLogBox', () => {
if (isReact18) { if (isReact18) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E336",
"description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined", "description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1230,7 +1218,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1230,7 +1218,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E336",
"description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined", "description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1346,7 +1333,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1346,7 +1333,6 @@ describe('ReactRefreshLogBox', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "anonymous error!", "description": "anonymous error!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1363,7 +1349,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1363,7 +1349,6 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "anonymous error!", "description": "anonymous error!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1405,7 +1390,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1405,7 +1390,6 @@ describe('ReactRefreshLogBox', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Invalid URL", "description": "Invalid URL",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime TypeError", "label": "Runtime TypeError",
......
...@@ -284,7 +284,6 @@ describe('ReactRefreshRegression', () => { ...@@ -284,7 +284,6 @@ describe('ReactRefreshRegression', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -299,7 +298,6 @@ describe('ReactRefreshRegression', () => { ...@@ -299,7 +298,6 @@ describe('ReactRefreshRegression', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -314,7 +312,6 @@ describe('ReactRefreshRegression', () => { ...@@ -314,7 +312,6 @@ describe('ReactRefreshRegression', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -21,7 +21,6 @@ describe('Cache Components Dev Errors', () => { ...@@ -21,7 +21,6 @@ describe('Cache Components Dev Errors', () => {
// soft-navigating to the page (see test below). // soft-navigating to the page (see test below).
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1432",
"description": "Next.js encountered the unstable value Math.random() while prerendering.", "description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -51,7 +50,6 @@ describe('Cache Components Dev Errors', () => { ...@@ -51,7 +50,6 @@ describe('Cache Components Dev Errors', () => {
// TODO: React should not include the anon stack in the Owner Stack. // TODO: React should not include the anon stack in the Owner Stack.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1432",
"description": "Next.js encountered the unstable value Math.random() while prerendering.", "description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -106,7 +104,6 @@ describe('Cache Components Dev Errors', () => { ...@@ -106,7 +104,6 @@ describe('Cache Components Dev Errors', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
......
...@@ -303,7 +303,6 @@ describe('cache-components-dev-streaming', () => { ...@@ -303,7 +303,6 @@ describe('cache-components-dev-streaming', () => {
// Cold cache miss: validation runs against a separate warm-cache render. // Cold cache miss: validation runs against a separate warm-cache render.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -328,7 +327,6 @@ describe('cache-components-dev-streaming', () => { ...@@ -328,7 +327,6 @@ describe('cache-components-dev-streaming', () => {
// and the cached value is re-served rather than recomputed. // and the cached value is re-served rather than recomputed.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -350,7 +348,6 @@ describe('cache-components-dev-streaming', () => { ...@@ -350,7 +348,6 @@ describe('cache-components-dev-streaming', () => {
// Cold cache miss: validation runs against a separate warm-cache render. // Cold cache miss: validation runs against a separate warm-cache render.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1432",
"description": "Next.js encountered the unstable value Date() while prerendering.", "description": "Next.js encountered the unstable value Date() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -375,7 +372,6 @@ describe('cache-components-dev-streaming', () => { ...@@ -375,7 +372,6 @@ describe('cache-components-dev-streaming', () => {
// and the cached value is re-served rather than recomputed. // and the cached value is re-served rather than recomputed.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1432",
"description": "Next.js encountered the unstable value Date() while prerendering.", "description": "Next.js encountered the unstable value Date() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
......
...@@ -71,7 +71,6 @@ describe('dev-validation-worker-source-maps', () => { ...@@ -71,7 +71,6 @@ describe('dev-validation-worker-source-maps', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -123,7 +122,6 @@ describe('dev-validation-worker-source-maps', () => { ...@@ -123,7 +122,6 @@ describe('dev-validation-worker-source-maps', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
...@@ -179,7 +177,6 @@ describe('dev-validation-worker-source-maps', () => { ...@@ -179,7 +177,6 @@ describe('dev-validation-worker-source-maps', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1440",
"description": "Next.js encountered uncached data during prerendering.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Blocking Route", "label": "Blocking Route",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment