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.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-devtools/index.js +1 -1
- package/dist/compiled/next-devtools/index.js.map +1 -1
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/dev/middleware-turbopack.js +2 -20
- package/dist/esm/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/esm/server/dev/middleware-webpack.js +13 -10
- package/dist/esm/server/dev/middleware-webpack.js.map +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/source-maps.js +38 -0
- package/dist/esm/server/lib/source-maps.js.map +1 -0
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/patch-error-inspect.js +3 -32
- package/dist/esm/server/patch-error-inspect.js.map +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/dev/middleware-turbopack.js +2 -20
- package/dist/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/server/dev/middleware-webpack.d.ts +4 -4
- package/dist/server/dev/middleware-webpack.js +14 -14
- package/dist/server/dev/middleware-webpack.js.map +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/source-maps.d.ts +36 -0
- package/dist/server/lib/source-maps.js +57 -0
- package/dist/server/lib/source-maps.js.map +1 -0
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/patch-error-inspect.d.ts +1 -20
- package/dist/server/patch-error-inspect.js +3 -32
- package/dist/server/patch-error-inspect.js.map +1 -1
- package/dist/shared/lib/canary-only.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
@@ -3,10 +3,10 @@ import path from 'path';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'url';
|
4
4
|
import { SourceMapConsumer } from 'next/dist/compiled/source-map08';
|
5
5
|
import { getSourceMapFromFile } from './get-source-map-from-file';
|
6
|
+
import { findApplicableSourceMapPayload, sourceMapIgnoreListsEverything } from '../lib/source-maps';
|
6
7
|
import { openFileInEditor } from '../../next-devtools/server/launch-editor';
|
7
8
|
import { getOriginalCodeFrame } from '../../next-devtools/server/shared';
|
8
9
|
import { middlewareResponse } from '../../next-devtools/server/middleware-response';
|
9
|
-
export { getSourceMapFromFile };
|
10
10
|
import { formatFrameSourceFile } from '../../next-devtools/shared/webpack-module-path';
|
11
11
|
import { inspect } from 'util';
|
12
12
|
function shouldIgnoreSource(sourceURL) {
|
@@ -163,7 +163,8 @@ async function getSourceMapFromCompilation(id, compilation) {
|
|
163
163
|
return undefined;
|
164
164
|
}
|
165
165
|
}
|
166
|
-
async function getSource(
|
166
|
+
async function getSource(frame, options) {
|
167
|
+
let sourceURL = frame.file ?? '';
|
167
168
|
const { getCompilations } = options;
|
168
169
|
// Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.
|
169
170
|
sourceURL = sourceURL.replace(/(.*)\/(?=file:\/\/)/, '');
|
@@ -183,8 +184,9 @@ async function getSource(sourceURL, options) {
|
|
183
184
|
const sourceMapPayload = nativeSourceMap.payload;
|
184
185
|
return {
|
185
186
|
type: 'file',
|
186
|
-
sourceMap: sourceMapPayload,
|
187
|
-
ignoredSources: getIgnoredSources(
|
187
|
+
sourceMap: findApplicableSourceMapPayload(frame.lineNumber ?? 0, frame.column ?? 0, sourceMapPayload),
|
188
|
+
ignoredSources: getIgnoredSources(// @ts-expect-error -- TODO: Support IndexSourceMap
|
189
|
+
sourceMapPayload),
|
188
190
|
moduleURL: sourceURL
|
189
191
|
};
|
190
192
|
}
|
@@ -246,13 +248,9 @@ function getOriginalStackFrames({ isServer, isEdgeServer, isAppDirectory, frames
|
|
246
248
|
};
|
247
249
|
})));
|
248
250
|
}
|
249
|
-
function sourceMapIgnoreListsEverything(sourceMap) {
|
250
|
-
var _sourceMap_ignoreList;
|
251
|
-
return sourceMap.sources.length === ((_sourceMap_ignoreList = sourceMap.ignoreList) == null ? void 0 : _sourceMap_ignoreList.length);
|
252
|
-
}
|
253
251
|
async function getOriginalStackFrame({ isServer, isEdgeServer, isAppDirectory, frame, clientStats, serverStats, edgeServerStats, rootDirectory }) {
|
254
252
|
const filename = frame.file ?? '';
|
255
|
-
const source = await getSource(
|
253
|
+
const source = await getSource(frame, {
|
256
254
|
getCompilations: ()=>{
|
257
255
|
const compilations = [];
|
258
256
|
// Try Client Compilation first. In `pages` we leverage
|
@@ -406,7 +404,12 @@ export function getSourceMapMiddleware(options) {
|
|
406
404
|
}
|
407
405
|
let source;
|
408
406
|
try {
|
409
|
-
source = await getSource(
|
407
|
+
source = await getSource({
|
408
|
+
file: filename,
|
409
|
+
// Webpack doesn't use Index Source Maps
|
410
|
+
lineNumber: null,
|
411
|
+
column: null
|
412
|
+
}, {
|
410
413
|
getCompilations: ()=>{
|
411
414
|
const compilations = [];
|
412
415
|
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":["findSourceMap","path","fileURLToPath","pathToFileURL","SourceMapConsumer","getSourceMapFromFile","openFileInEditor","getOriginalCodeFrame","middlewareResponse","formatFrameSourceFile","inspect","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","cause","console","error","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","ignoredByDefault","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","getSource","options","getCompilations","nativeSourceMap","sourceMapPayload","payload","isAbsolute","href","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","sourceMapIgnoreListsEverything","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","isSrcDir","req","res","next","pathname","searchParams","URL","method","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","openEditorResult","isAppRelativePath","relativeFilePath","absoluteFilePath","join","internalServerError","found","notFound","noContent","getSourceMapMiddleware","stats"],"mappings":"AAAA,SAASA,aAAa,QAAwB,SAAQ;AACtD,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,EAAEC,aAAa,QAAQ,MAAK;AAClD,SACEC,iBAAiB,QAEZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,gBAAgB,QAAQ,2CAA0C;AAC3E,SACEC,oBAAoB,QAIf,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,iDAAgD;AACnF,SAASH,oBAAoB,GAAE;AAQ/B,SAASI,qBAAqB,QAAQ,iDAAgD;AAEtF,SAASC,OAAO,QAAQ,OAAM;AAE9B,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,SAAWH,WAAWI,WAAW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EA,OAAO,SAAS2B,uBAAuB7D,OAItC;IACC,MAAM,EAAEY,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGd;IAEtD,OAAO,eACLgC,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAG,IAAIC,IAAI,CAAC,QAAQ,EAAEL,IAAItE,GAAG,EAAE;QAE/D,IAAIyE,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,MAAMV,WAAWY,aAAa7D,GAAG,CAAC;QAElC,IAAI,CAACiD,UAAU;YACb,OAAOhH,mBAAmB+H,UAAU,CAACN;QACvC;QAEA,IAAItG;QAEJ,IAAI;YACFA,SAAS,MAAMoE,UAAUyB,UAAU;gBACjCvB,iBAAiB;oBACf,MAAMwB,eAAsC,EAAE;oBAE9C,KAAK,MAAMqC,SAAS;wBAClBlD;wBACAC;wBACAC;qBACD,CAAE;wBACD,IAAIgD,yBAAAA,MAAO7I,WAAW,EAAE;4BACtBwG,aAAaC,IAAI,CAACoC,MAAM7I,WAAW;wBACrC;oBACF;oBAEA,OAAOwG;gBACT;YACF;QACF,EAAE,OAAOtF,OAAO;YACd,OAAO3B,mBAAmBiJ,mBAAmB,CAACxB,KAAK9F;QACrD;QAEA,IAAI,CAACR,QAAQ;YACX,OAAOnB,mBAAmBoJ,SAAS,CAAC3B;QACtC;QAEA,OAAOzH,mBAAmBuI,IAAI,CAACd,KAAKtG,OAAOG,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":["findSourceMap","path","fileURLToPath","pathToFileURL","SourceMapConsumer","getSourceMapFromFile","findApplicableSourceMapPayload","sourceMapIgnoreListsEverything","openFileInEditor","getOriginalCodeFrame","middlewareResponse","formatFrameSourceFile","inspect","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","cause","console","error","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","ignoredByDefault","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","getSource","options","getCompilations","nativeSourceMap","sourceMapPayload","payload","isAbsolute","href","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","isSrcDir","req","res","next","pathname","searchParams","URL","method","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","openEditorResult","isAppRelativePath","relativeFilePath","absoluteFilePath","join","internalServerError","found","notFound","noContent","getSourceMapMiddleware","stats"],"mappings":"AAAA,SAASA,aAAa,QAAwB,SAAQ;AACtD,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,EAAEC,aAAa,QAAQ,MAAK;AA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;qBACD,CAAE;wBACD,IAAI+C,yBAAAA,MAAO5I,WAAW,EAAE;4BACtBuG,aAAaC,IAAI,CAACoC,MAAM5I,WAAW;wBACrC;oBACF;oBAEA,OAAOuG;gBACT;YACF;QAEJ,EAAE,OAAOrF,OAAO;YACd,OAAO3B,mBAAmBgJ,mBAAmB,CAACxB,KAAK7F;QACrD;QAEA,IAAI,CAACR,QAAQ;YACX,OAAOnB,mBAAmBmJ,SAAS,CAAC3B;QACtC;QAEA,OAAOxH,mBAAmBsI,IAAI,CAACd,KAAKrG,OAAOG,SAAS;IACtD;AACF","ignoreList":[0]}
|
@@ -12,7 +12,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
12
12
|
} else {
|
13
13
|
bundlerSuffix = '';
|
14
14
|
}
|
15
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.
|
15
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.116"}`))}${bundlerSuffix}`);
|
16
16
|
if (appUrl) {
|
17
17
|
Log.bootstrap(`- Local: ${appUrl}`);
|
18
18
|
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* https://tc39.es/source-map/#index-map
|
3
|
+
*/ export function sourceMapIgnoreListsEverything(sourceMap) {
|
4
|
+
return sourceMap.ignoreList !== undefined && sourceMap.sources.length === sourceMap.ignoreList.length;
|
5
|
+
}
|
6
|
+
/**
|
7
|
+
* Finds the sourcemap payload applicable to a given frame.
|
8
|
+
* Equal to the input unless an Index Source Map is used.
|
9
|
+
*/ export function findApplicableSourceMapPayload(line, column, payload) {
|
10
|
+
if ('sections' in payload) {
|
11
|
+
if (payload.sections.length === 0) {
|
12
|
+
return undefined;
|
13
|
+
}
|
14
|
+
// Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
|
15
|
+
// Therefore the last section that has an offset less than or equal to the frame is the applicable one.
|
16
|
+
const sections = payload.sections;
|
17
|
+
let left = 0;
|
18
|
+
let right = sections.length - 1;
|
19
|
+
let result = null;
|
20
|
+
while(left <= right){
|
21
|
+
// fast Math.floor
|
22
|
+
const middle = ~~((left + right) / 2);
|
23
|
+
const section = sections[middle];
|
24
|
+
const offset = section.offset;
|
25
|
+
if (offset.line < line || offset.line === line && offset.column <= column) {
|
26
|
+
result = section;
|
27
|
+
left = middle + 1;
|
28
|
+
} else {
|
29
|
+
right = middle - 1;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return result === null ? undefined : result.map;
|
33
|
+
} else {
|
34
|
+
return payload;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
//# 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":["sourceMapIgnoreListsEverything","sourceMap","ignoreList","undefined","sources","length","findApplicableSourceMapPayload","line","column","payload","sections","left","right","result","middle","section","offset","map"],"mappings":"AAAA;;CAEC,GAkCD,OAAO,SAASA,+BACdC,SAAgC;IAEhC,OACEA,UAAUC,UAAU,KAAKC,aACzBF,UAAUG,OAAO,CAACC,MAAM,KAAKJ,UAAUC,UAAU,CAACG,MAAM;AAE5D;AAEA;;;CAGC,GACD,OAAO,SAASC,+BACdC,IAAY,EACZC,MAAc,EACdC,OAA+B;IAE/B,IAAI,cAAcA,SAAS;QACzB,IAAIA,QAAQC,QAAQ,CAACL,MAAM,KAAK,GAAG;YACjC,OAAOF;QACT;QAEA,2FAA2F;QAC3F,uGAAuG;QACvG,MAAMO,WAAWD,QAAQC,QAAQ;QACjC,IAAIC,OAAO;QACX,IAAIC,QAAQF,SAASL,MAAM,GAAG;QAC9B,IAAIQ,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,OAAOV,YAAYU,OAAOI,GAAG;IACjD,OAAO;QACL,OAAOR;IACT;AACF","ignoreList":[0]}
|
@@ -103,7 +103,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
103
103
|
export async function startServer(serverOptions) {
|
104
104
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
105
105
|
let { port } = serverOptions;
|
106
|
-
process.title = `next-server (v${"15.4.0-canary.
|
106
|
+
process.title = `next-server (v${"15.4.0-canary.116"})`;
|
107
107
|
let handlersReady = ()=>{};
|
108
108
|
let handlersError = ()=>{};
|
109
109
|
let handlersPromise = new Promise((resolve, reject)=>{
|
@@ -2,6 +2,7 @@ import { findSourceMap as nativeFindSourceMap } from 'module';
|
|
2
2
|
import * as path from 'path';
|
3
3
|
import * as url from 'url';
|
4
4
|
import { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map';
|
5
|
+
import { findApplicableSourceMapPayload, sourceMapIgnoreListsEverything } from './lib/source-maps';
|
5
6
|
import { parseStack } from './lib/parse-stack';
|
6
7
|
import { getOriginalCodeFrame } from '../next-devtools/server/shared';
|
7
8
|
import { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external';
|
@@ -54,25 +55,6 @@ function shouldIgnoreListGeneratedFrame(file) {
|
|
54
55
|
function shouldIgnoreListOriginalFrame(file) {
|
55
56
|
return file.includes('node_modules');
|
56
57
|
}
|
57
|
-
/**
|
58
|
-
* Finds the sourcemap payload applicable to a given frame.
|
59
|
-
* Equal to the input unless an Index Source Map is used.
|
60
|
-
*/ function findApplicableSourceMapPayload(frame, payload) {
|
61
|
-
if ('sections' in payload) {
|
62
|
-
const frameLine = frame.lineNumber ?? 0;
|
63
|
-
const frameColumn = frame.column ?? 0;
|
64
|
-
// Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
|
65
|
-
// Therefore the last section that has an offset less than or equal to the frame is the applicable one.
|
66
|
-
// TODO(veil): Binary search
|
67
|
-
let section = payload.sections[0];
|
68
|
-
for(let i = 0; i < payload.sections.length && payload.sections[i].offset.line <= frameLine && payload.sections[i].offset.column <= frameColumn; i++){
|
69
|
-
section = payload.sections[i];
|
70
|
-
}
|
71
|
-
return section === undefined ? undefined : section.map;
|
72
|
-
} else {
|
73
|
-
return payload;
|
74
|
-
}
|
75
|
-
}
|
76
58
|
function createUnsourcemappedFrame(frame) {
|
77
59
|
return {
|
78
60
|
stack: {
|
@@ -86,17 +68,6 @@ function createUnsourcemappedFrame(frame) {
|
|
86
68
|
code: null
|
87
69
|
};
|
88
70
|
}
|
89
|
-
function sourceMapIgnoreListsEverything(sourceMap) {
|
90
|
-
var _sourceMap_ignoreList;
|
91
|
-
if ('sections' in sourceMap) {
|
92
|
-
// If sections are present, the ignoreList is not used.
|
93
|
-
// This is because sections are used to ignore-list everything.
|
94
|
-
return sourceMap.sections.every((section)=>{
|
95
|
-
return sourceMapIgnoreListsEverything(section.map);
|
96
|
-
});
|
97
|
-
}
|
98
|
-
return sourceMap.sources.length === ((_sourceMap_ignoreList = sourceMap.ignoreList) == null ? void 0 : _sourceMap_ignoreList.length);
|
99
|
-
}
|
100
71
|
/**
|
101
72
|
* @param frame
|
102
73
|
* @param sourceMapCache
|
@@ -169,7 +140,8 @@ function sourceMapIgnoreListsEverything(sourceMap) {
|
|
169
140
|
column: frame.column ?? 0,
|
170
141
|
line: frame.lineNumber ?? 1
|
171
142
|
});
|
172
|
-
|
143
|
+
const applicableSourceMap = findApplicableSourceMapPayload(frame.lineNumber ?? 0, frame.column ?? 0, sourceMapPayload);
|
144
|
+
let ignored = applicableSourceMap !== undefined && sourceMapIgnoreListsEverything(applicableSourceMap);
|
173
145
|
if (sourcePosition.source === null) {
|
174
146
|
return {
|
175
147
|
stack: {
|
@@ -183,7 +155,6 @@ function sourceMapIgnoreListsEverything(sourceMap) {
|
|
183
155
|
code: null
|
184
156
|
};
|
185
157
|
}
|
186
|
-
const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMapPayload);
|
187
158
|
// TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
|
188
159
|
if (applicableSourceMap === undefined) {
|
189
160
|
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":["findSourceMap","nativeFindSourceMap","path","url","SourceMapConsumer","SyncSourceMapConsumer","parseStack","getOriginalCodeFrame","workUnitAsyncStorage","dim","bundlerFindSourceMapPayload","undefined","setBundlerFindSourceMapImplementation","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","relative","process","cwd","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","cause","console","set","sourcePosition","originalPositionFor","source","applicableSourceMap","sourceIndex","indexOf","originalFrame","replace","codeFrame","Object","defineProperty","sourceContent","sourceContentFor","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","Map","sourceMappedStack","sourceFrame","sourcemappedFrame","sourceMapError","newError","Error","key","prototype","hasOwnProperty","call","patchErrorInspectNodeJS","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","exit","originalCustomInspect","value","enumerable","writable","patchErrorInspectEdgeLite","format"],"mappings":"AAAA,SACEA,iBAAiBC,mBAAmB,QAE/B,SAAQ;AACf,YAAYC,UAAU,OAAM;AAC5B,YAAYC,SAAS,MAAK;AAE1B,SAASC,qBAAqBC,qBAAqB,QAAQ,gCAA+B;AAE1F,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,GAAG,QAAQ,oBAAmB;AAKvC,6CAA6C;AAC7C,iHAAiH;AACjH,8DAA8D;AAC9D,uCAAuC;AACvC,IAAIC,8BAAoD,IAAMC;AAE9D,OAAO,SAASC,sCACdC,2BAAiD;IAEjDH,8BAA8BG;AAChC;AAmCA,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,kB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OjH,qBAAqB2G,IAAI,CAAC;YAC/B,MAAMd,WAAWD,eAAe,IAAI,EAAE,CAAC;YAEvC,MAAMgB,wBAAwB,AAACf,QAAgB,CAACQ,cAAc;YAC9D,8BAA8B;YAC9B3B,OAAOC,cAAc,CAACkB,UAAUQ,eAAe;gBAC7CQ,OAAO1G;gBACP2G,YAAY;gBACZC,UAAU;YACZ;YACA,IAAI;gBACF,OAAOE,OAAOpB;YAChB,SAAU;;gBACNA,QAAgB,CAACQ,cAAc,GAAGO;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":["findSourceMap","nativeFindSourceMap","path","url","SourceMapConsumer","SyncSourceMapConsumer","findApplicableSourceMapPayload","sourceMapIgnoreListsEverything","parseStack","getOriginalCodeFrame","workUnitAsyncStorage","dim","bundlerFindSourceMapPayload","undefined","setBundlerFindSourceMapImplementation","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","relative","process","cwd","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","payload","cause","console","set","map","sourcePosition","originalPositionFor","line","applicableSourceMap","source","sourceIndex","sources","indexOf","ignoreList","originalFrame","replace","codeFrame","Object","defineProperty","sourceContent","sourceContentFor","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","Map","sourceMappedStack","sourceFrame","sourcemappedFrame","sourceMapError","newError","Error","key","prototype","hasOwnProperty","call","patchErrorInspectNodeJS","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","exit","originalCustomInspect","value","enumerable","writable","patchErrorInspectEdgeLite","format"],"mappings":"AAAA,SAASA,iBAAiBC,mBAAmB,QAAQ,SAAQ;AAC7D,YAAYC,UAAU,OAAM;AAC5B,YAAYC,SAAS,MAAK;AAE1B,SAASC,qBAAqBC,qBAAqB,QAAQ,gCAA+B;AAE1F,SAEEC,8BAA8B,EAC9BC,8BAA8B,QACzB,oBAAmB;AAC1B,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,oBAA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_env___NEXT_VERSION;
|
3
|
-
return !((_process_env___NEXT_VERSION = "15.4.0-canary.
|
3
|
+
return !((_process_env___NEXT_VERSION = "15.4.0-canary.116") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
4
4
|
}
|
5
5
|
export class CanaryOnlyError extends Error {
|
6
6
|
constructor(arg){
|
@@ -142,7 +142,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
142
142
|
}
|
143
143
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
144
144
|
const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
145
|
-
version: "15.4.0-canary.
|
145
|
+
version: "15.4.0-canary.116"
|
146
146
|
});
|
147
147
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
148
148
|
// of the current `next dev` invocation.
|