Skip to content

Commit a4fa113

Browse files
committed
suppor relative paths in patch-error-inspect
1 parent a2d1cf3 commit a4fa113

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/next/src/server/patch-error-inspect.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,17 @@ function getSourcemappedFrameIfPossible(
196196
}
197197
sourceMapPayload = maybeSourceMapPayload
198198
try {
199+
// Pass the source map URL as the second parameter so that the consumer
200+
// can resolve relative paths in the source map's `sources` array.
201+
// This is important for Turbopack-generated source maps which use relative paths.
202+
// For most bundlers (Turbopack, Webpack), the source map is in a file with .map extension.
203+
// We don't have access to the actual sourceMappingURL from Node's findSourceMap API,
204+
// but this heuristic works for standard bundler output.
205+
const sourceMapURL = sourceURL + '.map'
199206
sourceMapConsumer = new SyncSourceMapConsumer(
200-
// @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string
201-
sourceMapPayload
207+
sourceMapPayload,
208+
/** @ts-expect-error */
209+
sourceMapURL
202210
)
203211
} catch (cause) {
204212
// We should not log an actual error instance here because that will re-enter

0 commit comments

Comments
 (0)