Skip to content

Commit

Permalink
Shorten unsourcemapped absolute locations in terminal stacktraces
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 13, 2024
1 parent 2f696a1 commit bdd827e
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 @@ -87,7 +87,14 @@ function getSourcemappedFrameIfPossible(
let sourceMap: SyncSourceMapConsumer
let rawSourceMap: ModernRawSourceMap
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 bdd827e

Please sign in to comment.