next 15.4.0-canary.114 → 15.4.0-canary.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack-config.js +2 -2
  5. package/dist/client/app-bootstrap.js +1 -1
  6. package/dist/client/index.js +1 -1
  7. package/dist/compiled/next-devtools/index.js +1 -1
  8. package/dist/compiled/next-devtools/index.js.map +1 -1
  9. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
  10. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  11. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
  12. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
  13. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
  14. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
  15. package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
  16. package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
  17. package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
  18. package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
  19. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
  20. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  21. package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
  22. package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
  23. package/dist/compiled/next-server/server.runtime.prod.js +1 -1
  24. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  25. package/dist/esm/build/index.js +2 -2
  26. package/dist/esm/build/swc/index.js +1 -1
  27. package/dist/esm/build/webpack-config.js +2 -2
  28. package/dist/esm/client/app-bootstrap.js +1 -1
  29. package/dist/esm/client/index.js +1 -1
  30. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  31. package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
  32. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  33. package/dist/esm/server/dev/middleware-turbopack.js +2 -20
  34. package/dist/esm/server/dev/middleware-turbopack.js.map +1 -1
  35. package/dist/esm/server/dev/middleware-webpack.js +13 -10
  36. package/dist/esm/server/dev/middleware-webpack.js.map +1 -1
  37. package/dist/esm/server/lib/app-info-log.js +1 -1
  38. package/dist/esm/server/lib/source-maps.js +38 -0
  39. package/dist/esm/server/lib/source-maps.js.map +1 -0
  40. package/dist/esm/server/lib/start-server.js +1 -1
  41. package/dist/esm/server/patch-error-inspect.js +3 -32
  42. package/dist/esm/server/patch-error-inspect.js.map +1 -1
  43. package/dist/esm/shared/lib/canary-only.js +1 -1
  44. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  45. package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
  46. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  47. package/dist/server/dev/middleware-turbopack.js +2 -20
  48. package/dist/server/dev/middleware-turbopack.js.map +1 -1
  49. package/dist/server/dev/middleware-webpack.d.ts +4 -4
  50. package/dist/server/dev/middleware-webpack.js +14 -14
  51. package/dist/server/dev/middleware-webpack.js.map +1 -1
  52. package/dist/server/lib/app-info-log.js +1 -1
  53. package/dist/server/lib/source-maps.d.ts +36 -0
  54. package/dist/server/lib/source-maps.js +57 -0
  55. package/dist/server/lib/source-maps.js.map +1 -0
  56. package/dist/server/lib/start-server.js +1 -1
  57. package/dist/server/patch-error-inspect.d.ts +1 -20
  58. package/dist/server/patch-error-inspect.js +3 -32
  59. package/dist/server/patch-error-inspect.js.map +1 -1
  60. package/dist/shared/lib/canary-only.js +1 -1
  61. package/dist/telemetry/anonymous-meta.js +1 -1
  62. package/dist/telemetry/events/session-stopped.js +2 -2
  63. package/dist/telemetry/events/version.js +2 -2
  64. package/package.json +15 -15
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  createOriginalStackFrame: null,
7
7
  getIgnoredSources: null,
8
8
  getOverlayMiddleware: null,
9
- getSourceMapFromFile: null,
10
9
  getSourceMapMiddleware: null
11
10
  });
12
11
  function _export(target, all) {
@@ -25,9 +24,6 @@ _export(exports, {
25
24
  getOverlayMiddleware: function() {
26
25
  return getOverlayMiddleware;
27
26
  },
28
- getSourceMapFromFile: function() {
29
- return _getsourcemapfromfile.getSourceMapFromFile;
30
- },
31
27
  getSourceMapMiddleware: function() {
32
28
  return getSourceMapMiddleware;
33
29
  }
@@ -37,6 +33,7 @@ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
37
33
  const _url = require("url");
38
34
  const _sourcemap08 = require("next/dist/compiled/source-map08");
39
35
  const _getsourcemapfromfile = require("./get-source-map-from-file");
36
+ const _sourcemaps = require("../lib/source-maps");
40
37
  const _launcheditor = require("../../next-devtools/server/launch-editor");
41
38
  const _shared = require("../../next-devtools/server/shared");
42
39
  const _middlewareresponse = require("../../next-devtools/server/middleware-response");
@@ -201,7 +198,8 @@ async function getSourceMapFromCompilation(id, compilation) {
201
198
  return undefined;
202
199
  }
203
200
  }
204
- async function getSource(sourceURL, options) {
201
+ async function getSource(frame, options) {
202
+ let sourceURL = frame.file ?? '';
205
203
  const { getCompilations } = options;
206
204
  // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.
207
205
  sourceURL = sourceURL.replace(/(.*)\/(?=file:\/\/)/, '');
@@ -221,8 +219,9 @@ async function getSource(sourceURL, options) {
221
219
  const sourceMapPayload = nativeSourceMap.payload;
222
220
  return {
223
221
  type: 'file',
224
- sourceMap: sourceMapPayload,
225
- ignoredSources: getIgnoredSources(sourceMapPayload),
222
+ sourceMap: (0, _sourcemaps.findApplicableSourceMapPayload)(frame.lineNumber ?? 0, frame.column ?? 0, sourceMapPayload),
223
+ ignoredSources: getIgnoredSources(// @ts-expect-error -- TODO: Support IndexSourceMap
224
+ sourceMapPayload),
226
225
  moduleURL: sourceURL
227
226
  };
228
227
  }
@@ -284,13 +283,9 @@ function getOriginalStackFrames({ isServer, isEdgeServer, isAppDirectory, frames
284
283
  };
285
284
  })));
286
285
  }
287
- function sourceMapIgnoreListsEverything(sourceMap) {
288
- var _sourceMap_ignoreList;
289
- return sourceMap.sources.length === ((_sourceMap_ignoreList = sourceMap.ignoreList) == null ? void 0 : _sourceMap_ignoreList.length);
290
- }
291
286
  async function getOriginalStackFrame({ isServer, isEdgeServer, isAppDirectory, frame, clientStats, serverStats, edgeServerStats, rootDirectory }) {
292
287
  const filename = frame.file ?? '';
293
- const source = await getSource(filename, {
288
+ const source = await getSource(frame, {
294
289
  getCompilations: ()=>{
295
290
  const compilations = [];
296
291
  // Try Client Compilation first. In `pages` we leverage
@@ -349,7 +344,7 @@ async function getOriginalStackFrame({ isServer, isEdgeServer, isAppDirectory, f
349
344
  originalCodeFrame: null
350
345
  };
351
346
  }
352
- defaultStackFrame.ignored ||= sourceMapIgnoreListsEverything(source.sourceMap);
347
+ defaultStackFrame.ignored ||= (0, _sourcemaps.sourceMapIgnoreListsEverything)(source.sourceMap);
353
348
  const originalStackFrameResponse = await createOriginalStackFrame({
354
349
  ignoredByDefault: defaultStackFrame.ignored,
355
350
  frame,
@@ -444,7 +439,12 @@ function getSourceMapMiddleware(options) {
444
439
  }
445
440
  let source;
446
441
  try {
447
- source = await getSource(filename, {
442
+ source = await getSource({
443
+ file: filename,
444
+ // Webpack doesn't use Index Source Maps
445
+ lineNumber: null,
446
+ column: null
447
+ }, {
448
448
  getCompilations: ()=>{
449
449
  const compilations = [];
450
450
  for (const stats of [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/dev/middleware-webpack.ts"],"sourcesContent":["import { findSourceMap, type SourceMap } from 'module'\nimport path from 'path'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n} from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport { openFileInEditor } from '../../next-devtools/server/launch-editor'\nimport {\n getOriginalCodeFrame,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from '../../next-devtools/server/shared'\nimport { middlewareResponse } from '../../next-devtools/server/middleware-response'\nexport { getSourceMapFromFile }\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../../next-devtools/shared/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnoreSource(sourceURL: string): boolean {\n return (\n sourceURL.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n sourceURL.includes('next/dist') ||\n sourceURL.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n moduleURL: string\n }\n | {\n type: 'bundle'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n moduleURL: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n if (source.startsWith('file://')) {\n return fileURLToPath(source)\n }\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function findOriginalSourcePositionAndContent(\n sourceMap: RawSourceMap,\n position: { lineNumber: number | null; column: number | null }\n): Promise<SourceAttributes | null> {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMap)\n } catch (cause) {\n console.error(\n new Error(\n `${sourceMap.file}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n )\n return null\n }\n\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.lineNumber ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (position.column ?? 1) - 1,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(\n sourceMap: RawSourceMap & { ignoreList?: number[] }\n): IgnoredSources {\n const ignoreList = new Set<number>(sourceMap.ignoreList ?? [])\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const webpackSourceURL = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(webpackSourceURL)\n if (shouldIgnoreSource(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n ignoredByDefault,\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n /** setting this to true will not consult ignoreList */\n ignoredByDefault: boolean\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (() => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n return findOriginalSourcePositionAndContent(source.sourceMap, frame)\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n ignoredByDefault ||\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnoreSource(source.moduleURL)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.moduleURL\n : sourcePosition.source) || source.moduleURL\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n const resolvedFilePath = path.relative(rootDirectory, filePath)\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n sourceURL: string,\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n const { getCompilations } = options\n\n // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.\n sourceURL = sourceURL.replace(/(.*)\\/(?=file:\\/\\/)/, '')\n\n let nativeSourceMap: SourceMap | undefined\n try {\n nativeSourceMap = findSourceMap(sourceURL)\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n if (nativeSourceMap !== undefined) {\n const sourceMapPayload = nativeSourceMap.payload\n return {\n type: 'file',\n sourceMap: sourceMapPayload,\n ignoredSources: getIgnoredSources(sourceMapPayload),\n moduleURL: sourceURL,\n }\n }\n\n if (path.isAbsolute(sourceURL)) {\n sourceURL = pathToFileURL(sourceURL).href\n }\n\n if (sourceURL.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(sourceURL)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n moduleURL: sourceURL,\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = sourceURL\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const moduleURL = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n moduleURL,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nfunction sourceMapIgnoreListsEverything(\n sourceMap: RawSourceMap & { ignoreList?: number[] }\n): boolean {\n return sourceMap.sources.length === sourceMap.ignoreList?.length\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n let defaultNormalizedStackFrameLocation = frame.file\n if (\n defaultNormalizedStackFrameLocation !== null &&\n defaultNormalizedStackFrameLocation.startsWith('file://')\n ) {\n defaultNormalizedStackFrameLocation = path.relative(\n rootDirectory,\n fileURLToPath(defaultNormalizedStackFrameLocation)\n )\n }\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: defaultNormalizedStackFrameLocation,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnoreSource(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n defaultStackFrame.ignored ||= sourceMapIgnoreListsEverything(source.sourceMap)\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n ignoredByDefault: defaultStackFrame.ignored,\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n isSrcDir: boolean\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, isSrcDir, clientStats, serverStats, edgeServerStats } =\n options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return middlewareResponse.badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return middlewareResponse.json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (err) {\n return middlewareResponse.badRequest(res)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return middlewareResponse.badRequest(res)\n\n let openEditorResult\n const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'\n if (isAppRelativePath) {\n const relativeFilePath = searchParams.get('file') || ''\n const absoluteFilePath = path.join(\n rootDirectory,\n 'app',\n isSrcDir ? 'src' : '',\n relativeFilePath\n )\n openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1)\n } else {\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n openEditorResult = await openFileInEditor(\n filePath,\n frame.lineNumber,\n frame.column ?? 1\n )\n }\n if (openEditorResult.error) {\n console.error('Failed to launch editor:', openEditorResult.error)\n return middlewareResponse.internalServerError(\n res,\n openEditorResult.error\n )\n }\n if (!openEditorResult.found) {\n return middlewareResponse.notFound(res)\n }\n return middlewareResponse.noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n })\n } catch (error) {\n return middlewareResponse.internalServerError(res, error)\n }\n\n if (!source) {\n return middlewareResponse.noContent(res)\n }\n\n return middlewareResponse.json(res, source.sourceMap)\n }\n}\n"],"names":["createOriginalStackFrame","getIgnoredSources","getOverlayMiddleware","getSourceMapFromFile","getSourceMapMiddleware","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","fileURLToPath","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","SourceMapConsumer","cause","console","error","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","formatFrameSourceFile","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","ignoredByDefault","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","path","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getOriginalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","getSource","options","getCompilations","nativeSourceMap","findSourceMap","sourceMapPayload","payload","isAbsolute","pathToFileURL","href","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","inspect","colors","sourceMapIgnoreListsEverything","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","originalStackFrameResponse","isSrcDir","req","res","next","pathname","searchParams","URL","method","middlewareResponse","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","openEditorResult","isAppRelativePath","relativeFilePath","absoluteFilePath","join","openFileInEditor","internalServerError","found","notFound","noContent","stats"],"mappings":";;;;;;;;;;;;;;;;;;IAsLsBA,wBAAwB;eAAxBA;;IAnDNC,iBAAiB;eAAjBA;;IA6YAC,oBAAoB;eAApBA;;IA/fPC,oBAAoB;eAApBA,0CAAoB;;IA0mBbC,sBAAsB;eAAtBA;;;wBA3nB8B;6DAC7B;qBAC4B;6BAItC;sCAE8B;8BACJ;wBAM1B;oCAC4B;mCASG;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,sCAAkB,CAACoB,mBAAmB,CAAC1B,KAAKjG;QACrD;QAEA,IAAI,CAACV,QAAQ;YACX,OAAOiH,sCAAkB,CAACuB,SAAS,CAAC7B;QACtC;QAEA,OAAOM,sCAAkB,CAACS,IAAI,CAACf,KAAK3G,OAAOI,SAAS;IACtD;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../src/server/dev/middleware-webpack.ts"],"sourcesContent":["import { findSourceMap, type SourceMap } from 'module'\nimport path from 'path'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport { SourceMapConsumer } from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport {\n findApplicableSourceMapPayload,\n sourceMapIgnoreListsEverything,\n type BasicSourceMapPayload,\n type ModernSourceMapPayload,\n} from '../lib/source-maps'\nimport { openFileInEditor } from '../../next-devtools/server/launch-editor'\nimport {\n getOriginalCodeFrame,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from '../../next-devtools/server/shared'\nimport { middlewareResponse } from '../../next-devtools/server/middleware-response'\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../../next-devtools/shared/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnoreSource(sourceURL: string): boolean {\n return (\n sourceURL.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n sourceURL.includes('next/dist') ||\n sourceURL.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: BasicSourceMapPayload\n ignoredSources: IgnoredSources\n moduleURL: string\n }\n | {\n type: 'bundle'\n sourceMap: BasicSourceMapPayload\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n moduleURL: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n if (source.startsWith('file://')) {\n return fileURLToPath(source)\n }\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function findOriginalSourcePositionAndContent(\n sourceMap: ModernSourceMapPayload,\n position: { lineNumber: number | null; column: number | null }\n): Promise<SourceAttributes | null> {\n let consumer: SourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMap)\n } catch (cause) {\n console.error(\n new Error(\n `${sourceMap.file}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n )\n return null\n }\n\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.lineNumber ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (position.column ?? 1) - 1,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(\n sourceMap: RawSourceMap & { ignoreList?: number[] }\n): IgnoredSources {\n const ignoreList = new Set<number>(sourceMap.ignoreList ?? [])\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const webpackSourceURL = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(webpackSourceURL)\n if (shouldIgnoreSource(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n ignoredByDefault,\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n /** setting this to true will not consult ignoreList */\n ignoredByDefault: boolean\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (() => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n return findOriginalSourcePositionAndContent(source.sourceMap, frame)\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n ignoredByDefault ||\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnoreSource(source.moduleURL)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.moduleURL\n : sourcePosition.source) || source.moduleURL\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n const resolvedFilePath = path.relative(rootDirectory, filePath)\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n frame: {\n file: string | null\n lineNumber: number | null\n column: number | null\n },\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n let sourceURL = frame.file ?? ''\n const { getCompilations } = options\n\n // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.\n sourceURL = sourceURL.replace(/(.*)\\/(?=file:\\/\\/)/, '')\n\n let nativeSourceMap: SourceMap | undefined\n try {\n nativeSourceMap = findSourceMap(sourceURL)\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n if (nativeSourceMap !== undefined) {\n const sourceMapPayload = nativeSourceMap.payload\n return {\n type: 'file',\n sourceMap: findApplicableSourceMapPayload(\n frame.lineNumber ?? 0,\n frame.column ?? 0,\n sourceMapPayload\n )!,\n\n ignoredSources: getIgnoredSources(\n // @ts-expect-error -- TODO: Support IndexSourceMap\n sourceMapPayload\n ),\n moduleURL: sourceURL,\n }\n }\n\n if (path.isAbsolute(sourceURL)) {\n sourceURL = pathToFileURL(sourceURL).href\n }\n\n if (sourceURL.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(sourceURL)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n moduleURL: sourceURL,\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = sourceURL\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const moduleURL = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n moduleURL,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(frame, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n let defaultNormalizedStackFrameLocation = frame.file\n if (\n defaultNormalizedStackFrameLocation !== null &&\n defaultNormalizedStackFrameLocation.startsWith('file://')\n ) {\n defaultNormalizedStackFrameLocation = path.relative(\n rootDirectory,\n fileURLToPath(defaultNormalizedStackFrameLocation)\n )\n }\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: defaultNormalizedStackFrameLocation,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnoreSource(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n defaultStackFrame.ignored ||= sourceMapIgnoreListsEverything(source.sourceMap)\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n ignoredByDefault: defaultStackFrame.ignored,\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n isSrcDir: boolean\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, isSrcDir, clientStats, serverStats, edgeServerStats } =\n options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return middlewareResponse.badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return middlewareResponse.json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (err) {\n return middlewareResponse.badRequest(res)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return middlewareResponse.badRequest(res)\n\n let openEditorResult\n const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'\n if (isAppRelativePath) {\n const relativeFilePath = searchParams.get('file') || ''\n const absoluteFilePath = path.join(\n rootDirectory,\n 'app',\n isSrcDir ? 'src' : '',\n relativeFilePath\n )\n openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1)\n } else {\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n openEditorResult = await openFileInEditor(\n filePath,\n frame.lineNumber,\n frame.column ?? 1\n )\n }\n if (openEditorResult.error) {\n console.error('Failed to launch editor:', openEditorResult.error)\n return middlewareResponse.internalServerError(\n res,\n openEditorResult.error\n )\n }\n if (!openEditorResult.found) {\n return middlewareResponse.notFound(res)\n }\n return middlewareResponse.noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(\n {\n file: filename,\n // Webpack doesn't use Index Source Maps\n lineNumber: null,\n column: null,\n },\n {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n }\n )\n } catch (error) {\n return middlewareResponse.internalServerError(res, error)\n }\n\n if (!source) {\n return middlewareResponse.noContent(res)\n }\n\n return middlewareResponse.json(res, source.sourceMap)\n }\n}\n"],"names":["createOriginalStackFrame","getIgnoredSources","getOverlayMiddleware","getSourceMapMiddleware","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","fileURLToPath","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","SourceMapConsumer","cause","console","error","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","formatFrameSourceFile","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","ignoredByDefault","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","path","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getOriginalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","getSource","options","getCompilations","nativeSourceMap","findSourceMap","sourceMapPayload","payload","findApplicableSourceMapPayload","isAbsolute","pathToFileURL","href","getSourceMapFromFile","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","inspect","colors","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","sourceMapIgnoreListsEverything","originalStackFrameResponse","isSrcDir","req","res","next","pathname","searchParams","URL","method","middlewareResponse","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","openEditorResult","isAppRelativePath","relativeFilePath","absoluteFilePath","join","openFileInEditor","internalServerError","found","notFound","noContent","stats"],"mappings":";;;;;;;;;;;;;;;;;IAwLsBA,wBAAwB;eAAxBA;;IAnDNC,iBAAiB;eAAjBA;;IAoZAC,oBAAoB;eAApBA;;IA2GAC,sBAAsB;eAAtBA;;;wBApoB8B;6DAC7B;qBAC4B;6BACX;sCAEG;4BAM9B;8BAC0B;wBAM1B;oCAC4B;mCAQG;sBAEd;;;;;;AAExB,SAASC,mBAAmBC,SAAiB;IAC3C,OACEA,UAAUC,QAAQ,CAAC,mBACnB,2EAA2E;IAC3ED,UAAUC,QAAQ,CAAC,gBACnBD,UAAUE,UAAU,CAAC;AAEzB;AA6BA,SAASC,cACPC,EAAsB,EACtBC,WAAgC;IAEhC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE,GAAGF;IAEhC,OAAO;WAAIE;KAAQ,CAACC,IAAI,CAAC,CAACC,UAAWH,WAAWI,WAAW,CAACD,aAAYL;AAC1E;AAEA,SAASO,4BAA4BC,YAAgC;QAC5DA;IAAP,OAAOA,iCAAAA,sBAAAA,aAAcC,KAAK,CAAC,wCAApBD,mBAAyC,CAAC,EAAE;AACrD;AAEA,SAASE,cAAcC,MAAc;IACnC,IAAIA,OAAOb,UAAU,CAAC,YAAY;QAChC,OAAOc,IAAAA,kBAAa,EAACD;IACvB;IACA,OAAOA,OAAOE,OAAO,CAAC,qDAAqD;AAC7E;AAEA;;CAEC,GACD,eAAeC,qCACbC,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M,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAG,IAAIC,IAAI,CAAC,QAAQ,EAAEL,IAAI3E,GAAG,EAAE;QAE/D,IAAI8E,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,MAAMV,WAAWY,aAAalE,GAAG,CAAC;QAElC,IAAI,CAACsD,UAAU;YACb,OAAOe,sCAAkB,CAACC,UAAU,CAACP;QACvC;QAEA,IAAI7G;QAEJ,IAAI;YACFA,SAAS,MAAMuE,UACb;gBACE3D,MAAMwF;gBACN,wCAAwC;gBACxCpF,YAAY;gBACZC,QAAQ;YACV,GACA;gBACEwD,iBAAiB;oBACf,MAAM4B,eAAsC,EAAE;oBAE9C,KAAK,MAAMsC,SAAS;wBAClBnD;wBACAC;wBACAC;qBACD,CAAE;wBACD,IAAIiD,yBAAAA,MAAOrJ,WAAW,EAAE;4BACtB+G,aAAaC,IAAI,CAACqC,MAAMrJ,WAAW;wBACrC;oBACF;oBAEA,OAAO+G;gBACT;YACF;QAEJ,EAAE,OAAO3F,OAAO;YACd,OAAOyG,sCAAkB,CAACoB,mBAAmB,CAAC1B,KAAKnG;QACrD;QAEA,IAAI,CAACV,QAAQ;YACX,OAAOmH,sCAAkB,CAACuB,SAAS,CAAC7B;QACtC;QAEA,OAAOM,sCAAkB,CAACS,IAAI,CAACf,KAAK7G,OAAOI,SAAS;IACtD;AACF","ignoreList":[0]}
@@ -80,7 +80,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, maxEx
80
80
  } else {
81
81
  bundlerSuffix = '';
82
82
  }
83
- _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.4.0-canary.114"}`))}${bundlerSuffix}`);
83
+ _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.4.0-canary.116"}`))}${bundlerSuffix}`);
84
84
  if (appUrl) {
85
85
  _log.bootstrap(`- Local: ${appUrl}`);
86
86
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * https://tc39.es/source-map/#index-map
3
+ */
4
+ interface IndexSourceMapSection {
5
+ offset: {
6
+ line: number;
7
+ column: number;
8
+ };
9
+ map: BasicSourceMapPayload;
10
+ }
11
+ /** https://tc39.es/ecma426/#sec-index-source-map */
12
+ interface IndexSourceMap {
13
+ version: number;
14
+ file: string;
15
+ sections: IndexSourceMapSection[];
16
+ }
17
+ /** https://tc39.es/ecma426/#sec-source-map-format */
18
+ export interface BasicSourceMapPayload {
19
+ version: number;
20
+ /** WARNING: `file` is optional. */
21
+ file: string;
22
+ sourceRoot?: string;
23
+ /** WARNING: `sources[number]` can be `null`. */
24
+ sources: Array<string>;
25
+ names: Array<string>;
26
+ mappings: string;
27
+ ignoreList?: number[];
28
+ }
29
+ export type ModernSourceMapPayload = BasicSourceMapPayload | IndexSourceMap;
30
+ export declare function sourceMapIgnoreListsEverything(sourceMap: BasicSourceMapPayload): boolean;
31
+ /**
32
+ * Finds the sourcemap payload applicable to a given frame.
33
+ * Equal to the input unless an Index Source Map is used.
34
+ */
35
+ export declare function findApplicableSourceMapPayload(line: number, column: number, payload: ModernSourceMapPayload): BasicSourceMapPayload | undefined;
36
+ export {};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * https://tc39.es/source-map/#index-map
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ 0 && (module.exports = {
8
+ findApplicableSourceMapPayload: null,
9
+ sourceMapIgnoreListsEverything: null
10
+ });
11
+ function _export(target, all) {
12
+ for(var name in all)Object.defineProperty(target, name, {
13
+ enumerable: true,
14
+ get: all[name]
15
+ });
16
+ }
17
+ _export(exports, {
18
+ findApplicableSourceMapPayload: function() {
19
+ return findApplicableSourceMapPayload;
20
+ },
21
+ sourceMapIgnoreListsEverything: function() {
22
+ return sourceMapIgnoreListsEverything;
23
+ }
24
+ });
25
+ function sourceMapIgnoreListsEverything(sourceMap) {
26
+ return sourceMap.ignoreList !== undefined && sourceMap.sources.length === sourceMap.ignoreList.length;
27
+ }
28
+ function findApplicableSourceMapPayload(line, column, payload) {
29
+ if ('sections' in payload) {
30
+ if (payload.sections.length === 0) {
31
+ return undefined;
32
+ }
33
+ // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
34
+ // Therefore the last section that has an offset less than or equal to the frame is the applicable one.
35
+ const sections = payload.sections;
36
+ let left = 0;
37
+ let right = sections.length - 1;
38
+ let result = null;
39
+ while(left <= right){
40
+ // fast Math.floor
41
+ const middle = ~~((left + right) / 2);
42
+ const section = sections[middle];
43
+ const offset = section.offset;
44
+ if (offset.line < line || offset.line === line && offset.column <= column) {
45
+ result = section;
46
+ left = middle + 1;
47
+ } else {
48
+ right = middle - 1;
49
+ }
50
+ }
51
+ return result === null ? undefined : result.map;
52
+ } else {
53
+ return payload;
54
+ }
55
+ }
56
+
57
+ //# sourceMappingURL=source-maps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/lib/source-maps.ts"],"sourcesContent":["/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: BasicSourceMapPayload\n}\n\n// TODO(veil): Upstream types\n/** https://tc39.es/ecma426/#sec-index-source-map */\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\n/** https://tc39.es/ecma426/#sec-source-map-format */\nexport interface BasicSourceMapPayload {\n version: number\n // TODO: Move to https://github.com/jridgewell/sourcemaps which is actively maintained\n /** WARNING: `file` is optional. */\n file: string\n sourceRoot?: string\n // TODO: Move to https://github.com/jridgewell/sourcemaps which is actively maintained\n /** WARNING: `sources[number]` can be `null`. */\n sources: Array<string>\n names: Array<string>\n mappings: string\n ignoreList?: number[]\n}\n\nexport type ModernSourceMapPayload = BasicSourceMapPayload | IndexSourceMap\n\nexport function sourceMapIgnoreListsEverything(\n sourceMap: BasicSourceMapPayload\n): boolean {\n return (\n sourceMap.ignoreList !== undefined &&\n sourceMap.sources.length === sourceMap.ignoreList.length\n )\n}\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n */\nexport function findApplicableSourceMapPayload(\n line: number,\n column: number,\n payload: ModernSourceMapPayload\n): BasicSourceMapPayload | undefined {\n if ('sections' in payload) {\n if (payload.sections.length === 0) {\n return undefined\n }\n\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n const sections = payload.sections\n let left = 0\n let right = sections.length - 1\n let result: IndexSourceMapSection | null = null\n\n while (left <= right) {\n // fast Math.floor\n const middle = ~~((left + right) / 2)\n const section = sections[middle]\n const offset = section.offset\n\n if (\n offset.line < line ||\n (offset.line === line && offset.column <= column)\n ) {\n result = section\n left = middle + 1\n } else {\n right = middle - 1\n }\n }\n\n return result === null ? undefined : result.map\n } else {\n return payload\n }\n}\n"],"names":["findApplicableSourceMapPayload","sourceMapIgnoreListsEverything","sourceMap","ignoreList","undefined","sources","length","line","column","payload","sections","left","right","result","middle","section","offset","map"],"mappings":"AAAA;;CAEC;;;;;;;;;;;;;;;IA+CeA,8BAA8B;eAA9BA;;IAbAC,8BAA8B;eAA9BA;;;AAAT,SAASA,+BACdC,SAAgC;IAEhC,OACEA,UAAUC,UAAU,KAAKC,aACzBF,UAAUG,OAAO,CAACC,MAAM,KAAKJ,UAAUC,UAAU,CAACG,MAAM;AAE5D;AAMO,SAASN,+BACdO,IAAY,EACZC,MAAc,EACdC,OAA+B;IAE/B,IAAI,cAAcA,SAAS;QACzB,IAAIA,QAAQC,QAAQ,CAACJ,MAAM,KAAK,GAAG;YACjC,OAAOF;QACT;QAEA,2FAA2F;QAC3F,uGAAuG;QACvG,MAAMM,WAAWD,QAAQC,QAAQ;QACjC,IAAIC,OAAO;QACX,IAAIC,QAAQF,SAASJ,MAAM,GAAG;QAC9B,IAAIO,SAAuC;QAE3C,MAAOF,QAAQC,MAAO;YACpB,kBAAkB;YAClB,MAAME,SAAS,CAAC,CAAE,CAAA,AAACH,CAAAA,OAAOC,KAAI,IAAK,CAAA;YACnC,MAAMG,UAAUL,QAAQ,CAACI,OAAO;YAChC,MAAME,SAASD,QAAQC,MAAM;YAE7B,IACEA,OAAOT,IAAI,GAAGA,QACbS,OAAOT,IAAI,KAAKA,QAAQS,OAAOR,MAAM,IAAIA,QAC1C;gBACAK,SAASE;gBACTJ,OAAOG,SAAS;YAClB,OAAO;gBACLF,QAAQE,SAAS;YACnB;QACF;QAEA,OAAOD,WAAW,OAAOT,YAAYS,OAAOI,GAAG;IACjD,OAAO;QACL,OAAOR;IACT;AACF","ignoreList":[0]}
@@ -171,7 +171,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
171
171
  async function startServer(serverOptions) {
172
172
  const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
173
173
  let { port } = serverOptions;
174
- process.title = `next-server (v${"15.4.0-canary.114"})`;
174
+ process.title = `next-server (v${"15.4.0-canary.116"})`;
175
175
  let handlersReady = ()=>{};
176
176
  let handlersError = ()=>{};
177
177
  let handlersPromise = new Promise((resolve, reject)=>{
@@ -1,25 +1,6 @@
1
- import { type SourceMapPayload } from 'module';
1
+ import { type ModernSourceMapPayload } from './lib/source-maps';
2
2
  type FindSourceMapPayload = (sourceURL: string) => ModernSourceMapPayload | undefined;
3
3
  export declare function setBundlerFindSourceMapImplementation(findSourceMapImplementation: FindSourceMapPayload): void;
4
- /**
5
- * https://tc39.es/source-map/#index-map
6
- */
7
- interface IndexSourceMapSection {
8
- offset: {
9
- line: number;
10
- column: number;
11
- };
12
- map: ModernRawSourceMap;
13
- }
14
- interface IndexSourceMap {
15
- version: number;
16
- file: string;
17
- sections: IndexSourceMapSection[];
18
- }
19
- interface ModernRawSourceMap extends SourceMapPayload {
20
- ignoreList?: number[];
21
- }
22
- export type ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap;
23
4
  export declare function patchErrorInspectNodeJS(errorConstructor: ErrorConstructor): void;
24
5
  export declare function patchErrorInspectEdgeLite(errorConstructor: ErrorConstructor): void;
25
6
  export {};
@@ -28,6 +28,7 @@ const _module = require("module");
28
28
  const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
29
29
  const _url = /*#__PURE__*/ _interop_require_wildcard(require("url"));
30
30
  const _sourcemap = require("next/dist/compiled/source-map");
31
+ const _sourcemaps = require("./lib/source-maps");
31
32
  const _parsestack = require("./lib/parse-stack");
32
33
  const _shared = require("../next-devtools/server/shared");
33
34
  const _workunitasyncstorageexternal = require("./app-render/work-unit-async-storage.external");
@@ -121,25 +122,6 @@ function shouldIgnoreListGeneratedFrame(file) {
121
122
  function shouldIgnoreListOriginalFrame(file) {
122
123
  return file.includes('node_modules');
123
124
  }
124
- /**
125
- * Finds the sourcemap payload applicable to a given frame.
126
- * Equal to the input unless an Index Source Map is used.
127
- */ function findApplicableSourceMapPayload(frame, payload) {
128
- if ('sections' in payload) {
129
- const frameLine = frame.lineNumber ?? 0;
130
- const frameColumn = frame.column ?? 0;
131
- // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
132
- // Therefore the last section that has an offset less than or equal to the frame is the applicable one.
133
- // TODO(veil): Binary search
134
- let section = payload.sections[0];
135
- for(let i = 0; i < payload.sections.length && payload.sections[i].offset.line <= frameLine && payload.sections[i].offset.column <= frameColumn; i++){
136
- section = payload.sections[i];
137
- }
138
- return section === undefined ? undefined : section.map;
139
- } else {
140
- return payload;
141
- }
142
- }
143
125
  function createUnsourcemappedFrame(frame) {
144
126
  return {
145
127
  stack: {
@@ -153,17 +135,6 @@ function createUnsourcemappedFrame(frame) {
153
135
  code: null
154
136
  };
155
137
  }
156
- function sourceMapIgnoreListsEverything(sourceMap) {
157
- var _sourceMap_ignoreList;
158
- if ('sections' in sourceMap) {
159
- // If sections are present, the ignoreList is not used.
160
- // This is because sections are used to ignore-list everything.
161
- return sourceMap.sections.every((section)=>{
162
- return sourceMapIgnoreListsEverything(section.map);
163
- });
164
- }
165
- return sourceMap.sources.length === ((_sourceMap_ignoreList = sourceMap.ignoreList) == null ? void 0 : _sourceMap_ignoreList.length);
166
- }
167
138
  /**
168
139
  * @param frame
169
140
  * @param sourceMapCache
@@ -236,7 +207,8 @@ function sourceMapIgnoreListsEverything(sourceMap) {
236
207
  column: frame.column ?? 0,
237
208
  line: frame.lineNumber ?? 1
238
209
  });
239
- let ignored = sourceMapIgnoreListsEverything(sourceMapPayload);
210
+ const applicableSourceMap = (0, _sourcemaps.findApplicableSourceMapPayload)(frame.lineNumber ?? 0, frame.column ?? 0, sourceMapPayload);
211
+ let ignored = applicableSourceMap !== undefined && (0, _sourcemaps.sourceMapIgnoreListsEverything)(applicableSourceMap);
240
212
  if (sourcePosition.source === null) {
241
213
  return {
242
214
  stack: {
@@ -250,7 +222,6 @@ function sourceMapIgnoreListsEverything(sourceMap) {
250
222
  code: null
251
223
  };
252
224
  }
253
- const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMapPayload);
254
225
  // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
255
226
  if (applicableSourceMap === undefined) {
256
227
  console.error('No applicable source map found in sections for frame', frame);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/patch-error-inspect.ts"],"sourcesContent":["import {\n findSourceMap as nativeFindSourceMap,\n type SourceMapPayload,\n} from 'module'\nimport * as path from 'path'\nimport * as url from 'url'\nimport type * as util from 'util'\nimport { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { parseStack } from './lib/parse-stack'\nimport { getOriginalCodeFrame } from '../next-devtools/server/shared'\nimport { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external'\nimport { dim } from '../lib/picocolors'\n\ntype FindSourceMapPayload = (\n sourceURL: string\n) => ModernSourceMapPayload | undefined\n// Find a source map using the bundler's API.\n// This is only a fallback for when Node.js fails to due to bugs e.g. https://github.com/nodejs/node/issues/52102\n// TODO: Remove once all supported Node.js versions are fixed.\n// TODO(veil): Set from Webpack as well\nlet bundlerFindSourceMapPayload: FindSourceMapPayload = () => undefined\n\nexport function setBundlerFindSourceMapImplementation(\n findSourceMapImplementation: FindSourceMapPayload\n): void {\n bundlerFindSourceMapPayload = findSourceMapImplementation\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\nexport type ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\n\ninterface IgnoreableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceMapCache = Map<\n string,\n null | { map: SyncSourceMapConsumer; payload: ModernSourceMapPayload }\n>\n\nfunction frameToString(frame: StackFrame): string {\n let sourceLocation = frame.lineNumber !== null ? `:${frame.lineNumber}` : ''\n if (frame.column !== null && sourceLocation !== '') {\n sourceLocation += `:${frame.column}`\n }\n\n let fileLocation: string | null\n if (\n frame.file !== null &&\n frame.file.startsWith('file://') &&\n URL.canParse(frame.file)\n ) {\n // If not relative to CWD, the path is ambiguous to IDEs and clicking will prompt to select the file first.\n // In a multi-app repo, this leads to potentially larger file names but will make clicking snappy.\n // There's no tradeoff for the cases where `dir` in `next dev [dir]` is omitted\n // since relative to cwd is both the shortest and snappiest.\n fileLocation = path.relative(process.cwd(), url.fileURLToPath(frame.file))\n } else if (frame.file !== null && frame.file.startsWith('/')) {\n fileLocation = path.relative(process.cwd(), frame.file)\n } else {\n fileLocation = frame.file\n }\n\n return frame.methodName\n ? ` at ${frame.methodName} (${fileLocation}${sourceLocation})`\n : ` at ${fileLocation}${sourceLocation}`\n}\n\nfunction computeErrorName(error: Error): string {\n // TODO: Node.js seems to use a different algorithm\n // class ReadonlyRequestCookiesError extends Error {}` would read `ReadonlyRequestCookiesError: [...]`\n // in the stack i.e. seems like under certain conditions it favors the constructor name.\n return error.name || 'Error'\n}\n\nfunction prepareUnsourcemappedStackTrace(\n error: Error,\n structuredStackTrace: any[]\n): string {\n const name = computeErrorName(error)\n const message = error.message || ''\n let stack = name + ': ' + message\n for (let i = 0; i < structuredStackTrace.length; i++) {\n stack += '\\n at ' + structuredStackTrace[i].toString()\n }\n return stack\n}\n\nfunction shouldIgnoreListGeneratedFrame(file: string): boolean {\n return file.startsWith('node:') || file.includes('node_modules')\n}\n\nfunction shouldIgnoreListOriginalFrame(file: string): boolean {\n return file.includes('node_modules')\n}\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n */\nfunction findApplicableSourceMapPayload(\n frame: StackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.lineNumber ?? 0\n const frameColumn = frame.column ?? 0\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\ninterface SourcemappableStackFrame extends StackFrame {\n file: NonNullable<StackFrame['file']>\n}\n\ninterface SourceMappedFrame {\n stack: IgnoreableStackFrame\n // DEV only\n code: string | null\n}\n\nfunction createUnsourcemappedFrame(\n frame: SourcemappableStackFrame\n): SourceMappedFrame {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n}\n\nfunction sourceMapIgnoreListsEverything(\n sourceMap: ModernSourceMapPayload\n): boolean {\n if ('sections' in sourceMap) {\n // If sections are present, the ignoreList is not used.\n // This is because sections are used to ignore-list everything.\n return sourceMap.sections.every((section) => {\n return sourceMapIgnoreListsEverything(section.map)\n })\n }\n return sourceMap.sources.length === sourceMap.ignoreList?.length\n}\n\n/**\n * @param frame\n * @param sourceMapCache\n * @returns The original frame if not sourcemapped.\n */\nfunction getSourcemappedFrameIfPossible(\n frame: SourcemappableStackFrame,\n sourceMapCache: SourceMapCache,\n inspectOptions: util.InspectOptions\n): {\n stack: IgnoreableStackFrame\n code: string | null\n} {\n const sourceMapCacheEntry = sourceMapCache.get(frame.file)\n let sourceMapConsumer: SyncSourceMapConsumer\n let sourceMapPayload: ModernSourceMapPayload\n if (sourceMapCacheEntry === undefined) {\n let sourceURL = frame.file\n // e.g. \"/APP/.next/server/chunks/ssr/[root-of-the-server]__2934a0._.js\"\n // will be keyed by Node.js as \"file:///APP/.next/server/chunks/ssr/[root-of-the-server]__2934a0._.js\".\n // This is likely caused by `callsite.toString()` in `Error.prepareStackTrace converting file URLs to paths.\n if (sourceURL.startsWith('/')) {\n sourceURL = url.pathToFileURL(frame.file).toString()\n }\n let maybeSourceMapPayload: ModernSourceMapPayload | undefined\n try {\n const sourceMap = nativeFindSourceMap(sourceURL)\n maybeSourceMapPayload = sourceMap?.payload\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n // If loading fails once, it'll fail every time.\n // So set the cache to avoid duplicate errors.\n sourceMapCache.set(frame.file, null)\n // Don't even fall back to the bundler because it might be not as strict\n // with regards to parsing and then we fail later once we consume the\n // source map payload.\n // This essentially avoids a redundant error where we fail here and then\n // later on consumption because the bundler just handed back an invalid\n // source map.\n return createUnsourcemappedFrame(frame)\n }\n if (maybeSourceMapPayload === undefined) {\n maybeSourceMapPayload = bundlerFindSourceMapPayload(sourceURL)\n }\n\n if (maybeSourceMapPayload === undefined) {\n return createUnsourcemappedFrame(frame)\n }\n sourceMapPayload = maybeSourceMapPayload\n try {\n sourceMapConsumer = new SyncSourceMapConsumer(\n // @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string\n sourceMapPayload\n )\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n // If creating the consumer fails once, it'll fail every time.\n // So set the cache to avoid duplicate errors.\n sourceMapCache.set(frame.file, null)\n return createUnsourcemappedFrame(frame)\n }\n sourceMapCache.set(frame.file, {\n map: sourceMapConsumer,\n payload: sourceMapPayload,\n })\n } else if (sourceMapCacheEntry === null) {\n // We failed earlier getting the payload or consumer.\n // Just return an unsourcemapped frame.\n // Errors will already be logged.\n return createUnsourcemappedFrame(frame)\n } else {\n sourceMapConsumer = sourceMapCacheEntry.map\n sourceMapPayload = sourceMapCacheEntry.payload\n }\n\n const sourcePosition = sourceMapConsumer.originalPositionFor({\n column: frame.column ?? 0,\n line: frame.lineNumber ?? 1,\n })\n\n let ignored = sourceMapIgnoreListsEverything(sourceMapPayload)\n if (sourcePosition.source === null) {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: ignored || shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n }\n\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMapPayload\n )\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n if (applicableSourceMap === undefined) {\n console.error('No applicable source map found in sections for frame', frame)\n } else if (!ignored && shouldIgnoreListOriginalFrame(sourcePosition.source)) {\n // Externals may be libraries that don't ship ignoreLists.\n // This is really taking control away from libraries.\n // They should still ship `ignoreList` so that attached debuggers ignore-list their frames.\n // TODO: Maybe only ignore library sourcemaps if `ignoreList` is absent?\n // Though keep in mind that Turbopack omits empty `ignoreList`.\n // So if we establish this convention, we should communicate it to the ecosystem.\n ignored = true\n } else if (!ignored) {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n sourcePosition.source\n )\n ignored = applicableSourceMap.ignoreList?.includes(sourceIndex) ?? false\n }\n\n const originalFrame: IgnoreableStackFrame = {\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n methodName: frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n column: sourcePosition.column,\n file: sourcePosition.source,\n lineNumber: sourcePosition.line,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n /** undefined = not yet computed*/\n let codeFrame: string | null | undefined\n\n return Object.defineProperty(\n {\n stack: originalFrame,\n code: null,\n },\n 'code',\n {\n get: () => {\n if (codeFrame === undefined) {\n const sourceContent: string | null =\n sourceMapConsumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n codeFrame = getOriginalCodeFrame(\n originalFrame,\n sourceContent,\n inspectOptions.colors\n )\n }\n return codeFrame\n },\n }\n )\n}\n\nfunction parseAndSourceMap(\n error: Error,\n inspectOptions: util.InspectOptions\n): string {\n // TODO(veil): Expose as CLI arg or config option. Useful for local debugging.\n const showIgnoreListed = false\n // We overwrote Error.prepareStackTrace earlier so error.stack is not sourcemapped.\n let unparsedStack = String(error.stack)\n // We could just read it from `error.stack`.\n // This works around cases where a 3rd party `Error.prepareStackTrace` implementation\n // doesn't implement the name computation correctly.\n const errorName = computeErrorName(error)\n\n let idx = unparsedStack.indexOf('react_stack_bottom_frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n } else {\n idx = unparsedStack.indexOf('react-stack-bottom-frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n }\n }\n if (idx !== -1 && !showIgnoreListed) {\n // Cut off everything after the bottom frame since it'll be React internals.\n unparsedStack = unparsedStack.slice(0, idx)\n }\n\n const unsourcemappedStack = parseStack(unparsedStack)\n const sourceMapCache: SourceMapCache = new Map()\n\n let sourceMappedStack = ''\n let sourceFrame: null | string = null\n for (const frame of unsourcemappedStack) {\n if (frame.file === null) {\n sourceMappedStack += '\\n' + frameToString(frame)\n } else {\n const sourcemappedFrame = getSourcemappedFrameIfPossible(\n // We narrowed this earlier by bailing if `frame.file` is null.\n frame as SourcemappableStackFrame,\n sourceMapCache,\n inspectOptions\n )\n\n if (\n sourceFrame === null &&\n // TODO: Is this the right choice?\n !sourcemappedFrame.stack.ignored &&\n sourcemappedFrame.code !== null\n ) {\n sourceFrame = sourcemappedFrame.code\n }\n if (!sourcemappedFrame.stack.ignored) {\n // TODO: Consider what happens if every frame is ignore listed.\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed && !inspectOptions.colors) {\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed) {\n sourceMappedStack += '\\n' + dim(frameToString(sourcemappedFrame.stack))\n }\n }\n }\n\n return (\n errorName +\n ': ' +\n error.message +\n sourceMappedStack +\n (sourceFrame !== null ? '\\n' + sourceFrame : '')\n )\n}\n\nfunction sourceMapError(\n this: void,\n error: Error,\n inspectOptions: util.InspectOptions\n): Error {\n // Create a new Error object with the source mapping applied and then use native\n // Node.js formatting on the result.\n const newError =\n error.cause !== undefined\n ? // Setting an undefined `cause` would print `[cause]: undefined`\n new Error(error.message, { cause: error.cause })\n : new Error(error.message)\n\n // TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name\n newError.stack = parseAndSourceMap(error, inspectOptions)\n\n for (const key in error) {\n if (!Object.prototype.hasOwnProperty.call(newError, key)) {\n // @ts-expect-error -- We're copying all enumerable properties.\n // So they definitely exist on `this` and obviously have no type on `newError` (yet)\n newError[key] = error[key]\n }\n }\n\n return newError\n}\n\nexport function patchErrorInspectNodeJS(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('nodejs.util.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function (\n depth: number,\n inspectOptions: util.InspectOptions,\n inspect: typeof util.inspect\n ): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, inspectOptions)\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n // { customInspect: false } would result in `error.cause` not using our inspect.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return inspect(newError, {\n ...inspectOptions,\n depth:\n (inspectOptions.depth ??\n // Default in Node.js\n 2) - depth,\n })\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n\nexport function patchErrorInspectEdgeLite(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('edge-runtime.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function ({\n format,\n }: {\n format: (...args: unknown[]) => string\n }): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, {})\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return format(newError)\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n"],"names":["patchErrorInspectEdgeLite","patchErrorInspectNodeJS","setBundlerFindSourceMapImplementation","bundlerFindSourceMapPayload","undefined","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","path","relative","process","cwd","url","fileURLToPath","methodName","computeErrorName","error","name","prepareUnsourcemappedStackTrace","structuredStackTrace","message","stack","i","length","toString","shouldIgnoreListGeneratedFrame","includes","shouldIgnoreListOriginalFrame","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","offset","line","map","createUnsourcemappedFrame","arguments","ignored","code","sourceMapIgnoreListsEverything","sourceMap","every","sources","ignoreList","getSourcemappedFrameIfPossible","sourceMapCache","inspectOptions","sourceMapCacheEntry","get","sourceMapConsumer","sourceMapPayload","sourceURL","pathToFileURL","maybeSourceMapPayload","nativeFindSourceMap","cause","console","set","SyncSourceMapConsumer","sourcePosition","originalPositionFor","source","applicableSourceMap","sourceIndex","indexOf","originalFrame","replace","codeFrame","Object","defineProperty","sourceContent","sourceContentFor","getOriginalCodeFrame","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","parseStack","Map","sourceMappedStack","sourceFrame","sourcemappedFrame","dim","sourceMapError","newError","Error","key","prototype","hasOwnProperty","call","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","workUnitAsyncStorage","exit","originalCustomInspect","value","enumerable","writable","format"],"mappings":";;;;;;;;;;;;;;;;IAkfgBA,yBAAyB;eAAzBA;;IAzCAC,uBAAuB;eAAvBA;;IAlbAC,qCAAqC;eAArCA;;;wBApBT;8DACe;6DACD;2BAEsC;4BAEhC;wBACU;8CACA;4BACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAc;oBACjBuD,OACE,AAACvD,CAAAA,eAAeuD,KAAK,IACnB,qBAAqB;oBACrB,CAAA,IAAKA;gBACX;YACF,SAAU;;gBACNX,QAAgB,CAACO,cAAc,GAAGQ;YACtC;QACF;IACF;AACF;AAEO,SAASnH,0BACd0G,gBAAkC;IAElC,MAAMC,gBAAgBC,OAAOC,GAAG,CAAC;IAEjCH,iBAAiBI,iBAAiB,GAAGpF;IAErC,0CAA0C;IAC1C,mFAAmF;IACnFgF,iBAAiBH,SAAS,CAACI,cAAc,GAAG,SAAU,EACpDY,MAAM,EAGP;QACC,gGAAgG;QAChG,OAAON,kDAAoB,CAACC,IAAI,CAAC;YAC/B,MAAMd,WAAWD,eAAe,IAAI,EAAE,CAAC;YAEvC,MAAMgB,wBAAwB,AAACf,QAAgB,CAACO,cAAc;YAC9D,8BAA8B;YAC9B7B,OAAOC,cAAc,CAACqB,UAAUO,eAAe;gBAC7CS,OAAOhH;gBACPiH,YAAY;gBACZC,UAAU;YACZ;YACA,IAAI;gBACF,OAAOC,OAAOnB;YAChB,SAAU;;gBACNA,QAAgB,CAACO,cAAc,GAAGQ;YACtC;QACF;IACF;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../src/server/patch-error-inspect.ts"],"sourcesContent":["import { findSourceMap as nativeFindSourceMap } from 'module'\nimport * as path from 'path'\nimport * as url from 'url'\nimport type * as util from 'util'\nimport { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n type ModernSourceMapPayload,\n findApplicableSourceMapPayload,\n sourceMapIgnoreListsEverything,\n} from './lib/source-maps'\nimport { parseStack } from './lib/parse-stack'\nimport { getOriginalCodeFrame } from '../next-devtools/server/shared'\nimport { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external'\nimport { dim } from '../lib/picocolors'\n\ntype FindSourceMapPayload = (\n sourceURL: string\n) => ModernSourceMapPayload | undefined\n// Find a source map using the bundler's API.\n// This is only a fallback for when Node.js fails to due to bugs e.g. https://github.com/nodejs/node/issues/52102\n// TODO: Remove once all supported Node.js versions are fixed.\n// TODO(veil): Set from Webpack as well\nlet bundlerFindSourceMapPayload: FindSourceMapPayload = () => undefined\n\nexport function setBundlerFindSourceMapImplementation(\n findSourceMapImplementation: FindSourceMapPayload\n): void {\n bundlerFindSourceMapPayload = findSourceMapImplementation\n}\n\ninterface IgnoreableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceMapCache = Map<\n string,\n null | { map: SyncSourceMapConsumer; payload: ModernSourceMapPayload }\n>\n\nfunction frameToString(frame: StackFrame): string {\n let sourceLocation = frame.lineNumber !== null ? `:${frame.lineNumber}` : ''\n if (frame.column !== null && sourceLocation !== '') {\n sourceLocation += `:${frame.column}`\n }\n\n let fileLocation: string | null\n if (\n frame.file !== null &&\n frame.file.startsWith('file://') &&\n URL.canParse(frame.file)\n ) {\n // If not relative to CWD, the path is ambiguous to IDEs and clicking will prompt to select the file first.\n // In a multi-app repo, this leads to potentially larger file names but will make clicking snappy.\n // There's no tradeoff for the cases where `dir` in `next dev [dir]` is omitted\n // since relative to cwd is both the shortest and snappiest.\n fileLocation = path.relative(process.cwd(), url.fileURLToPath(frame.file))\n } else if (frame.file !== null && frame.file.startsWith('/')) {\n fileLocation = path.relative(process.cwd(), frame.file)\n } else {\n fileLocation = frame.file\n }\n\n return frame.methodName\n ? ` at ${frame.methodName} (${fileLocation}${sourceLocation})`\n : ` at ${fileLocation}${sourceLocation}`\n}\n\nfunction computeErrorName(error: Error): string {\n // TODO: Node.js seems to use a different algorithm\n // class ReadonlyRequestCookiesError extends Error {}` would read `ReadonlyRequestCookiesError: [...]`\n // in the stack i.e. seems like under certain conditions it favors the constructor name.\n return error.name || 'Error'\n}\n\nfunction prepareUnsourcemappedStackTrace(\n error: Error,\n structuredStackTrace: any[]\n): string {\n const name = computeErrorName(error)\n const message = error.message || ''\n let stack = name + ': ' + message\n for (let i = 0; i < structuredStackTrace.length; i++) {\n stack += '\\n at ' + structuredStackTrace[i].toString()\n }\n return stack\n}\n\nfunction shouldIgnoreListGeneratedFrame(file: string): boolean {\n return file.startsWith('node:') || file.includes('node_modules')\n}\n\nfunction shouldIgnoreListOriginalFrame(file: string): boolean {\n return file.includes('node_modules')\n}\n\ninterface SourcemappableStackFrame extends StackFrame {\n file: NonNullable<StackFrame['file']>\n}\n\ninterface SourceMappedFrame {\n stack: IgnoreableStackFrame\n // DEV only\n code: string | null\n}\n\nfunction createUnsourcemappedFrame(\n frame: SourcemappableStackFrame\n): SourceMappedFrame {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n}\n\n/**\n * @param frame\n * @param sourceMapCache\n * @returns The original frame if not sourcemapped.\n */\nfunction getSourcemappedFrameIfPossible(\n frame: SourcemappableStackFrame,\n sourceMapCache: SourceMapCache,\n inspectOptions: util.InspectOptions\n): {\n stack: IgnoreableStackFrame\n code: string | null\n} {\n const sourceMapCacheEntry = sourceMapCache.get(frame.file)\n let sourceMapConsumer: SyncSourceMapConsumer\n let sourceMapPayload: ModernSourceMapPayload\n if (sourceMapCacheEntry === undefined) {\n let sourceURL = frame.file\n // e.g. \"/APP/.next/server/chunks/ssr/[root-of-the-server]__2934a0._.js\"\n // will be keyed by Node.js as \"file:///APP/.next/server/chunks/ssr/[root-of-the-server]__2934a0._.js\".\n // This is likely caused by `callsite.toString()` in `Error.prepareStackTrace converting file URLs to paths.\n if (sourceURL.startsWith('/')) {\n sourceURL = url.pathToFileURL(frame.file).toString()\n }\n let maybeSourceMapPayload: ModernSourceMapPayload | undefined\n try {\n const sourceMap = nativeFindSourceMap(sourceURL)\n maybeSourceMapPayload = sourceMap?.payload\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n // If loading fails once, it'll fail every time.\n // So set the cache to avoid duplicate errors.\n sourceMapCache.set(frame.file, null)\n // Don't even fall back to the bundler because it might be not as strict\n // with regards to parsing and then we fail later once we consume the\n // source map payload.\n // This essentially avoids a redundant error where we fail here and then\n // later on consumption because the bundler just handed back an invalid\n // source map.\n return createUnsourcemappedFrame(frame)\n }\n if (maybeSourceMapPayload === undefined) {\n maybeSourceMapPayload = bundlerFindSourceMapPayload(sourceURL)\n }\n\n if (maybeSourceMapPayload === undefined) {\n return createUnsourcemappedFrame(frame)\n }\n sourceMapPayload = maybeSourceMapPayload\n try {\n sourceMapConsumer = new SyncSourceMapConsumer(\n // @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string\n sourceMapPayload\n )\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n // If creating the consumer fails once, it'll fail every time.\n // So set the cache to avoid duplicate errors.\n sourceMapCache.set(frame.file, null)\n return createUnsourcemappedFrame(frame)\n }\n sourceMapCache.set(frame.file, {\n map: sourceMapConsumer,\n payload: sourceMapPayload,\n })\n } else if (sourceMapCacheEntry === null) {\n // We failed earlier getting the payload or consumer.\n // Just return an unsourcemapped frame.\n // Errors will already be logged.\n return createUnsourcemappedFrame(frame)\n } else {\n sourceMapConsumer = sourceMapCacheEntry.map\n sourceMapPayload = sourceMapCacheEntry.payload\n }\n\n const sourcePosition = sourceMapConsumer.originalPositionFor({\n column: frame.column ?? 0,\n line: frame.lineNumber ?? 1,\n })\n\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame.lineNumber ?? 0,\n frame.column ?? 0,\n sourceMapPayload\n )\n let ignored =\n applicableSourceMap !== undefined &&\n sourceMapIgnoreListsEverything(applicableSourceMap)\n if (sourcePosition.source === null) {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: ignored || shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n }\n\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n if (applicableSourceMap === undefined) {\n console.error('No applicable source map found in sections for frame', frame)\n } else if (!ignored && shouldIgnoreListOriginalFrame(sourcePosition.source)) {\n // Externals may be libraries that don't ship ignoreLists.\n // This is really taking control away from libraries.\n // They should still ship `ignoreList` so that attached debuggers ignore-list their frames.\n // TODO: Maybe only ignore library sourcemaps if `ignoreList` is absent?\n // Though keep in mind that Turbopack omits empty `ignoreList`.\n // So if we establish this convention, we should communicate it to the ecosystem.\n ignored = true\n } else if (!ignored) {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n sourcePosition.source\n )\n ignored = applicableSourceMap.ignoreList?.includes(sourceIndex) ?? false\n }\n\n const originalFrame: IgnoreableStackFrame = {\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n methodName: frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n column: sourcePosition.column,\n file: sourcePosition.source,\n lineNumber: sourcePosition.line,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n /** undefined = not yet computed*/\n let codeFrame: string | null | undefined\n\n return Object.defineProperty(\n {\n stack: originalFrame,\n code: null,\n },\n 'code',\n {\n get: () => {\n if (codeFrame === undefined) {\n const sourceContent: string | null =\n sourceMapConsumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n codeFrame = getOriginalCodeFrame(\n originalFrame,\n sourceContent,\n inspectOptions.colors\n )\n }\n return codeFrame\n },\n }\n )\n}\n\nfunction parseAndSourceMap(\n error: Error,\n inspectOptions: util.InspectOptions\n): string {\n // TODO(veil): Expose as CLI arg or config option. Useful for local debugging.\n const showIgnoreListed = false\n // We overwrote Error.prepareStackTrace earlier so error.stack is not sourcemapped.\n let unparsedStack = String(error.stack)\n // We could just read it from `error.stack`.\n // This works around cases where a 3rd party `Error.prepareStackTrace` implementation\n // doesn't implement the name computation correctly.\n const errorName = computeErrorName(error)\n\n let idx = unparsedStack.indexOf('react_stack_bottom_frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n } else {\n idx = unparsedStack.indexOf('react-stack-bottom-frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n }\n }\n if (idx !== -1 && !showIgnoreListed) {\n // Cut off everything after the bottom frame since it'll be React internals.\n unparsedStack = unparsedStack.slice(0, idx)\n }\n\n const unsourcemappedStack = parseStack(unparsedStack)\n const sourceMapCache: SourceMapCache = new Map()\n\n let sourceMappedStack = ''\n let sourceFrame: null | string = null\n for (const frame of unsourcemappedStack) {\n if (frame.file === null) {\n sourceMappedStack += '\\n' + frameToString(frame)\n } else {\n const sourcemappedFrame = getSourcemappedFrameIfPossible(\n // We narrowed this earlier by bailing if `frame.file` is null.\n frame as SourcemappableStackFrame,\n sourceMapCache,\n inspectOptions\n )\n\n if (\n sourceFrame === null &&\n // TODO: Is this the right choice?\n !sourcemappedFrame.stack.ignored &&\n sourcemappedFrame.code !== null\n ) {\n sourceFrame = sourcemappedFrame.code\n }\n if (!sourcemappedFrame.stack.ignored) {\n // TODO: Consider what happens if every frame is ignore listed.\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed && !inspectOptions.colors) {\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed) {\n sourceMappedStack += '\\n' + dim(frameToString(sourcemappedFrame.stack))\n }\n }\n }\n\n return (\n errorName +\n ': ' +\n error.message +\n sourceMappedStack +\n (sourceFrame !== null ? '\\n' + sourceFrame : '')\n )\n}\n\nfunction sourceMapError(\n this: void,\n error: Error,\n inspectOptions: util.InspectOptions\n): Error {\n // Create a new Error object with the source mapping applied and then use native\n // Node.js formatting on the result.\n const newError =\n error.cause !== undefined\n ? // Setting an undefined `cause` would print `[cause]: undefined`\n new Error(error.message, { cause: error.cause })\n : new Error(error.message)\n\n // TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name\n newError.stack = parseAndSourceMap(error, inspectOptions)\n\n for (const key in error) {\n if (!Object.prototype.hasOwnProperty.call(newError, key)) {\n // @ts-expect-error -- We're copying all enumerable properties.\n // So they definitely exist on `this` and obviously have no type on `newError` (yet)\n newError[key] = error[key]\n }\n }\n\n return newError\n}\n\nexport function patchErrorInspectNodeJS(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('nodejs.util.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function (\n depth: number,\n inspectOptions: util.InspectOptions,\n inspect: typeof util.inspect\n ): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, inspectOptions)\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n // { customInspect: false } would result in `error.cause` not using our inspect.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return inspect(newError, {\n ...inspectOptions,\n depth:\n (inspectOptions.depth ??\n // Default in Node.js\n 2) - depth,\n })\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n\nexport function patchErrorInspectEdgeLite(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('edge-runtime.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function ({\n format,\n }: {\n format: (...args: unknown[]) => string\n }): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, {})\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return format(newError)\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n"],"names":["patchErrorInspectEdgeLite","patchErrorInspectNodeJS","setBundlerFindSourceMapImplementation","bundlerFindSourceMapPayload","undefined","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","path","relative","process","cwd","url","fileURLToPath","methodName","computeErrorName","error","name","prepareUnsourcemappedStackTrace","structuredStackTrace","message","stack","i","length","toString","shouldIgnoreListGeneratedFrame","includes","shouldIgnoreListOriginalFrame","createUnsourcemappedFrame","arguments","ignored","code","getSourcemappedFrameIfPossible","sourceMapCache","inspectOptions","sourceMapCacheEntry","get","sourceMapConsumer","sourceMapPayload","sourceURL","pathToFileURL","maybeSourceMapPayload","sourceMap","nativeFindSourceMap","payload","cause","console","set","SyncSourceMapConsumer","map","sourcePosition","originalPositionFor","line","applicableSourceMap","findApplicableSourceMapPayload","sourceMapIgnoreListsEverything","source","sourceIndex","sources","indexOf","ignoreList","originalFrame","replace","codeFrame","Object","defineProperty","sourceContent","sourceContentFor","getOriginalCodeFrame","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","parseStack","Map","sourceMappedStack","sourceFrame","sourcemappedFrame","dim","sourceMapError","newError","Error","key","prototype","hasOwnProperty","call","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","workUnitAsyncStorage","exit","originalCustomInspect","value","enumerable","writable","format"],"mappings":";;;;;;;;;;;;;;;;IAmbgBA,yBAAyB;eAAzBA;;IAzCAC,uBAAuB;eAAvBA;;IAjXAC,qCAAqC;eAArCA;;;wBAzBqC;8DAC/B;6DACD;2BAEsC;4BAMpD;4BACoB;wBACU;8CACA;4BACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKpB,6CAA6C;AAC7C,iHAAiH;AACjH,8DAA8D;AAC9D,uCAAuC;AACvC,IAAIC,8BAAoD,IAAMC;AAEvD,SAASF,sCACdG,2BAAiD;IAEjDF,8BAA8BE;AAChC;AAWA,SAASC,cAAcC,KAAiB;IACtC,IAAIC,iBAAiBD,MAAME,UAAU,KAAK,OAAO,CAAC,CAAC,EAAEF,MAAME,UAAU,EAAE,GAAG;IAC1E,IAAIF,MAAMG,MAAM,KAAK,QAAQF,mBAAmB,IAAI;QAClDA,kBAAkB,CAAC,CAAC,EAAED,MAAMG,MAAM,EAAE;IACtC;IAEA,IAAIC;IACJ,IACEJ,MAAMK,IAAI,KAAK,QACfL,MAAMK,IAAI,CAACC,UAAU,CAAC,cACtBC,IAAIC,QAAQ,CAACR,MAAMK,IAAI,GACvB;QACA,2GAA2G;QAC3G,kGAAkG;QAClG,+EAA+E;QAC/E,4DAA4D;QAC5DD,eAAeK,MAAKC,QAAQ,CAACC,QAAQC,GAAG,IAAIC,KAAIC,aAAa,CAACd,MAAMK,IAAI;IAC1E,OAAO,IAAIL,MAAMK,IAAI,KAAK,QAAQL,MAAMK,IAAI,CAACC,UAAU,CAAC,MAAM;QAC5DF,eAAeK,MAAKC,QAAQ,CAACC,QAAQC,GAAG,IAAIZ,MAAMK,IAAI;IACxD,OAAO;QACLD,eAAeJ,MAAMK,IAAI;IAC3B;IAEA,OAAOL,MAAMe,UAAU,GACnB,CAAC,OAAO,EAAEf,MAAMe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