Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import {
import { isParallelRouteSegment } from '../../../shared/lib/segment'
import { ensureLeadingSlash } from '../../../shared/lib/page-path/ensure-leading-slash'
import { Lockfile } from '../../../build/lockfile'
import { deobfuscateText } from '../../../shared/lib/magic-identifier'

export type SetupOpts = {
renderServer: LazyRenderServerInstance
Expand Down Expand Up @@ -1225,9 +1224,6 @@ async function startWatcher(
err: unknown,
type?: 'unhandledRejection' | 'uncaughtException' | 'warning' | 'app-dir'
) {
if (err instanceof Error) {
err.message = deobfuscateText(err.message)
}
if (err instanceof ModuleBuildError) {
// Errors that may come from issues from the user's code
Log.error(err.message)
Expand Down
7 changes: 5 additions & 2 deletions packages/next/src/server/patch-error-inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { parseStack, type StackFrame } from './lib/parse-stack'
import { getOriginalCodeFrame } from '../next-devtools/server/shared'
import { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external'
import { dim, italic } from '../lib/picocolors'
import { deobfuscateText } from '../shared/lib/magic-identifier'

type FindSourceMapPayload = (
sourceURL: string
Expand Down Expand Up @@ -443,11 +444,13 @@ function sourceMapError(
): Error {
// Create a new Error object with the source mapping applied and then use native
// Node.js formatting on the result.
// The vm may reference mangled symbols in error messages, so deobfuscate it.
const message = deobfuscateText(error.message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing? The error message should be free of these to begin with. This is hit in prod so it shouldn't have any dev magic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at the examples on the PR up stack

#85060

basically it is deobfuscating some dev-only mangling we do (in production SWC will minify).

I was wondering if this was a better place for the logic instead of 'just' where the dev server logs errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverting

const newError =
error.cause !== undefined
? // Setting an undefined `cause` would print `[cause]: undefined`
new Error(error.message, { cause: error.cause })
: new Error(error.message)
new Error(message, { cause: error.cause })
: new Error(message)

// TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name
newError.stack = parseAndSourceMap(error, inspectOptions)
Expand Down
Loading