Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f0fbc02f
Commit
f0fbc02f
authored
Jan 13, 2026
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert changes to server-source-maps.test.ts
parent
cc9c655c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
42 deletions
+51
-42
patch-error-inspect.ts
packages/next/src/server/patch-error-inspect.ts
+32
-33
server-source-maps.test.ts
...e2e/app-dir/server-source-maps/server-source-maps.test.ts
+19
-9
No files found.
packages/next/src/server/patch-error-inspect.ts
View file @
f0fbc02f
...
@@ -78,9 +78,9 @@ type NameMappingsByLine = Map<number, Array<{ column: number; name: string }>>
...
@@ -78,9 +78,9 @@ type NameMappingsByLine = Map<number, Array<{ column: number; name: string }>>
interface
SourceMapCacheEntry
{
interface
SourceMapCacheEntry
{
map
:
SyncSourceMapConsumer
map
:
SyncSourceMapConsumer
payload
:
ModernSourceMapPayload
payload
:
ModernSourceMapPayload
/** Cached name mappings for efficient lookup */
/** Cached name mappings for efficient lookup
, the SourceMapConsumer doesn't allow random access
*/
nameMappings
?:
NameMappingsByLine
nameMappings
?:
NameMappingsByLine
/** Cached generated source file content for name validation */
/** Cached generated source file content for name validation
, if `null` then we failed to read the file.
*/
generatedSource
?:
string
|
null
generatedSource
?:
string
|
null
/** File name (URL) for reading generated source */
/** File name (URL) for reading generated source */
fileName
:
string
fileName
:
string
...
@@ -374,7 +374,9 @@ function getSourcemappedFrameIfPossible(
...
@@ -374,7 +374,9 @@ function getSourcemappedFrameIfPossible(
}
}
let
maybeSourceMapPayload
:
ModernSourceMapPayload
|
undefined
let
maybeSourceMapPayload
:
ModernSourceMapPayload
|
undefined
try
{
try
{
console
.
error
(
'looking up source map for '
,
sourceURL
)
const
sourceMap
=
nativeFindSourceMap
(
sourceURL
)
const
sourceMap
=
nativeFindSourceMap
(
sourceURL
)
console
.
error
(
'
\
tfound source map'
)
maybeSourceMapPayload
=
sourceMap
?.
payload
maybeSourceMapPayload
=
sourceMap
?.
payload
}
catch
(
cause
)
{
}
catch
(
cause
)
{
// We should not log an actual error instance here because that will re-enter
// We should not log an actual error instance here because that will re-enter
...
@@ -393,10 +395,12 @@ function getSourcemappedFrameIfPossible(
...
@@ -393,10 +395,12 @@ function getSourcemappedFrameIfPossible(
// source map.
// source map.
return
createUnsourcemappedFrame
(
frame
)
return
createUnsourcemappedFrame
(
frame
)
}
}
console
.
error
(
'1: maybeSourceMapPayload='
,
maybeSourceMapPayload
)
if
(
maybeSourceMapPayload
===
undefined
)
{
if
(
maybeSourceMapPayload
===
undefined
)
{
maybeSourceMapPayload
=
bundlerFindSourceMapPayload
(
sourceURL
)
maybeSourceMapPayload
=
bundlerFindSourceMapPayload
(
sourceURL
)
}
}
console
.
error
(
'2: maybeSourceMapPayload='
,
maybeSourceMapPayload
)
if
(
maybeSourceMapPayload
===
undefined
)
{
if
(
maybeSourceMapPayload
===
undefined
)
{
return
createUnsourcemappedFrame
(
frame
)
return
createUnsourcemappedFrame
(
frame
)
}
}
...
@@ -408,11 +412,13 @@ function getSourcemappedFrameIfPossible(
...
@@ -408,11 +412,13 @@ function getSourcemappedFrameIfPossible(
// relative paths but is actually wrong (the chunk and sourcemap have different content hashes).
// relative paths but is actually wrong (the chunk and sourcemap have different content hashes).
// We are using the node API to read the sourcemap and it doesn't give us access to the URI.
// We are using the node API to read the sourcemap and it doesn't give us access to the URI.
const
sourceMapURL
=
sourceURL
+
'.map'
const
sourceMapURL
=
sourceURL
+
'.map'
console
.
error
(
'about to parse sourcemap for '
,
sourceURL
)
sourceMapConsumer
=
new
SyncSourceMapConsumer
(
sourceMapConsumer
=
new
SyncSourceMapConsumer
(
sourceMapPayload
,
sourceMapPayload
,
// @ts-expect-error: our typings don't include this parameter but it is here.
// @ts-expect-error: our typings don't include this parameter but it is here.
sourceMapURL
sourceMapURL
)
)
console
.
error
(
'
\
tparsed source map'
)
}
catch
(
cause
)
{
}
catch
(
cause
)
{
// We should not log an actual error instance here because that will re-enter
// We should not log an actual error instance here because that will re-enter
// this codepath during error inspection and could lead to infinite recursion.
// this codepath during error inspection and could lead to infinite recursion.
...
@@ -492,43 +498,33 @@ function getSourcemappedFrameIfPossible(
...
@@ -492,43 +498,33 @@ function getSourcemappedFrameIfPossible(
?.
replace
(
'__webpack_exports__.'
,
''
)
?.
replace
(
'__webpack_exports__.'
,
''
)
if
(
enclosingPosition
&&
sourceMapCacheEntry
&&
methodName
)
{
if
(
enclosingPosition
&&
sourceMapCacheEntry
&&
methodName
)
{
// Parse the methodName to extract components for reconstruction
// Parse methodName format: [async] [new] [TypeName.]functionName[ [as methodName]]
// Format: [async] [new] [TypeName.]functionName[ [as methodName]]
// We need to extract just the functionName part for deobfuscation
let
prefix
=
''
let
funcStart
=
0
let
remaining
=
methodName
let
funcEnd
=
methodName
.
length
// Extract "async " prefix
// Skip "async " prefix
if
(
remaining
.
startsWith
(
'async '
))
{
if
(
methodName
.
startsWith
(
'async '
))
{
prefix
+=
'async '
funcStart
=
6
remaining
=
remaining
.
slice
(
6
)
}
}
// Extract "new " prefix
// Skip "new " prefix
if
(
remaining
.
startsWith
(
'new '
))
{
if
(
methodName
.
startsWith
(
'new '
,
funcStart
))
{
prefix
+=
'new '
funcStart
+=
4
remaining
=
remaining
.
slice
(
4
)
}
}
// Extract " [as methodName]" suffix
// Find " [as methodName]" suffix
// Note: We keep the [as methodName] suffix unchanged since we can't
const
asIndex
=
methodName
.
indexOf
(
' [as '
,
funcStart
)
// deobfuscate property names - the enclosing position only tells us
// where the function is defined, not where it's accessed
let
asSuffix
=
''
const
asIndex
=
remaining
.
indexOf
(
' [as '
)
if
(
asIndex
!==
-
1
)
{
if
(
asIndex
!==
-
1
)
{
asSuffix
=
remaining
.
slice
(
asIndex
)
funcEnd
=
asIndex
remaining
=
remaining
.
slice
(
0
,
asIndex
)
}
}
// Extract TypeName. prefix (e.g., "Object.foo" -> typeName="Object.", functionName="foo")
// Find TypeName. prefix (after async/new, before [as])
let
typePrefix
=
''
const
dotIndex
=
methodName
.
lastIndexOf
(
'.'
,
funcEnd
)
const
dotIndex
=
remaining
.
lastIndexOf
(
'.'
)
// Use lastIndexOf for nested namespaces
if
(
dotIndex
!==
-
1
&&
dotIndex
>=
funcStart
)
{
if
(
dotIndex
!==
-
1
)
{
funcStart
=
dotIndex
+
1
typePrefix
=
remaining
.
slice
(
0
,
dotIndex
+
1
)
remaining
=
remaining
.
slice
(
dotIndex
+
1
)
}
}
// `remaining` is now the raw function name
const
rawFunctionName
=
methodName
.
slice
(
funcStart
,
funcEnd
)
const
rawFunctionName
=
remaining
const
deobfuscatedName
=
findNameAtPosition
(
const
deobfuscatedName
=
findNameAtPosition
(
getNameMappings
(
sourceMapCacheEntry
),
getNameMappings
(
sourceMapCacheEntry
),
...
@@ -539,8 +535,11 @@ function getSourcemappedFrameIfPossible(
...
@@ -539,8 +535,11 @@ function getSourcemappedFrameIfPossible(
)
)
if
(
deobfuscatedName
)
{
if
(
deobfuscatedName
)
{
// Reconstruct the method name with the deobfuscated function name
// Replace the function name portion, keeping prefix and suffix
methodName
=
prefix
+
typePrefix
+
deobfuscatedName
+
asSuffix
methodName
=
methodName
.
slice
(
0
,
funcStart
)
+
deobfuscatedName
+
methodName
.
slice
(
funcEnd
)
}
}
}
}
...
...
test/e2e/app-dir/server-source-maps/server-source-maps.test.ts
View file @
f0fbc02f
...
@@ -397,15 +397,25 @@ describe('app-dir - server source maps', () => {
...
@@ -397,15 +397,25 @@ describe('app-dir - server source maps', () => {
'
\
n'
'
\
n'
)
)
}
else
{
}
else
{
// Node.js is not fine with invalid URLs in vanilla source maps.
expect
(
normalizeCliOutput
(
next
.
cliOutput
.
slice
(
outputIndex
))).
toContain
(
// The specific paths in the output vary based on how the source map consumer
// Node.js is not fine with invalid URLs in vanilla source maps.
// resolves the invalid source URL. Just check for the key elements.
// Feel free to adjust these locations. They're just here to showcase
// Note: The "Invalid source map" warning may or may not appear depending on
// sourcemapping is broken on invalid sources.
// whether Node's findSourceMap throws or returns a successful-but-invalid result.
''
+
const
cliOutput
=
normalizeCliOutput
(
next
.
cliOutput
.
slice
(
outputIndex
))
`\nwebpack-internal:///(rsc)/./app/bad-sourcemap/page.js: Invalid source map. Only conformant source maps can be used to find the original code. Cause: TypeError [ERR_INVALID_ARG_TYPE]: The "payload" argument must be of type object. Received null`
+
expect
(
cliOutput
).
toContain
(
'Error: bad-sourcemap'
)
'
\
nError: bad-sourcemap'
+
expect
(
cliOutput
).
toContain
(
'at logError'
)
'
\
n at logError (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:12:19)'
+
expect
(
cliOutput
).
toContain
(
'at Page'
)
'
\
n at Page (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:15:5)'
)
// Expect the invalid sourcemap warning only once per render.
// Dynamic I/O renders three times.
// One from filterStackFrameDEV.
// One from findSourceMapURLDEV.
expect
(
normalizeCliOutput
(
next
.
cliOutput
.
slice
(
outputIndex
)).
split
(
'Invalid source map.'
).
length
-
1
).
toEqual
(
3
)
}
}
}
else
{
}
else
{
// Bundlers silently drop invalid sourcemaps.
// Bundlers silently drop invalid sourcemaps.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment