Skip to content

Commit

Permalink
Account for file URLs vs file paths
Browse files Browse the repository at this point in the history
A case where we encounter this is not known.
Only saw this while stepping through Node.js internals.
  • Loading branch information
eps1lon committed Nov 20, 2024
1 parent adc8a57 commit a055505
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/next/src/server/patch-error-inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ function getSourcemappedFrameIfPossible(
let sourceMap: SyncSourceMapConsumer
let sourceMapPayload: ModernSourceMapPayload
if (sourceMapCacheEntry === undefined) {
const moduleSourceMap = findSourceMap(frame.file)
let sourceURL = frame.file
// e.g. "/APP/.next/server/chunks/ssr/[root of the server]__2934a0._.js"
// will be keyed by Node.js as "file:///APP/.next/server/chunks/ssr/[root%20of%20the%20server]__2934a0._.js".
// This is likely caused by `callsite.toString()` in `Error.prepareStackTrace converting file URLs to paths.
if (sourceURL.startsWith('/')) {
sourceURL = url.pathToFileURL(frame.file).toString()
}
const moduleSourceMap = findSourceMap(sourceURL)
if (moduleSourceMap === undefined) {
return null
}
Expand Down

0 comments on commit a055505

Please sign in to comment.