Unverified Commit 11102729 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Handle more known protocols in stackframe locations (#76086)

parent c9ef4bd3
...@@ -284,7 +284,8 @@ ...@@ -284,7 +284,8 @@
}, },
"patchedDependencies": { "patchedDependencies": {
"webpack-sources@3.2.3": "patches/webpack-sources@3.2.3.patch", "webpack-sources@3.2.3": "patches/webpack-sources@3.2.3.patch",
"@storybook/react@8.5.2": "patches/@storybook__react@8.5.2.patch" "@storybook/react@8.5.2": "patches/@storybook__react@8.5.2.patch",
"stacktrace-parser@0.1.10": "patches/stacktrace-parser@0.1.10.patch"
} }
} }
} }
...@@ -9,26 +9,7 @@ describe('webpack-module-path', () => { ...@@ -9,26 +9,7 @@ describe('webpack-module-path', () => {
expect( expect(
isWebpackInternalResource('webpack-internal:///./src/hello.tsx') isWebpackInternalResource('webpack-internal:///./src/hello.tsx')
).toBe(true) ).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(rsc)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42dc'
)
).toBe(true)
expect(isWebpackInternalResource('webpack://_N_E/./src/hello.tsx')).toBe( expect(isWebpackInternalResource('webpack://_N_E/./src/hello.tsx')).toBe(
true true
) )
...@@ -47,31 +28,6 @@ describe('webpack-module-path', () => { ...@@ -47,31 +28,6 @@ describe('webpack-module-path', () => {
expect(formatFrameSourceFile('webpack-internal:///./src/hello.tsx')).toBe( expect(formatFrameSourceFile('webpack-internal:///./src/hello.tsx')).toBe(
'./src/hello.tsx' './src/hello.tsx'
) )
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(rsc)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42?0'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42dc'
)
).toBe('./src/hello.tsx')
expect(formatFrameSourceFile('webpack://_N_E/./src/hello.tsx')).toBe( expect(formatFrameSourceFile('webpack://_N_E/./src/hello.tsx')).toBe(
'./src/hello.tsx' './src/hello.tsx'
) )
......
const replacementRegExes = [ const replacementRegExes = [
/^(rsc:\/\/React\/[^/]+\/)/,
/^webpack-internal:\/\/\/(\([\w-]+\)\/)?/, /^webpack-internal:\/\/\/(\([\w-]+\)\/)?/,
/^(webpack:\/\/\/|webpack:\/\/(_N_E\/)?)(\([\w-]+\)\/)?/, /^(webpack:\/\/\/|webpack:\/\/(_N_E\/)?)(\([\w-]+\)\/)?/,
/\?\w+(\?\d+)?$/, // React replay error query param, .e.g. ?c69d?0, ?c69d
/\?\d+$/, // React's fakeFunctionIdx query param
] ]
export function isWebpackInternalResource(file: string) { export function isWebpackInternalResource(file: string) {
...@@ -20,8 +17,6 @@ export function isWebpackInternalResource(file: string) { ...@@ -20,8 +17,6 @@ export function isWebpackInternalResource(file: string) {
* Format the webpack internal id to original file path * Format the webpack internal id to original file path
* *
* webpack-internal:///./src/hello.tsx => ./src/hello.tsx * webpack-internal:///./src/hello.tsx => ./src/hello.tsx
* rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => ./src/hello.tsx
* rsc://React/Server/webpack:///app/indirection.tsx?14cb?0 => app/indirection.tsx
* webpack://_N_E/./src/hello.tsx => ./src/hello.tsx * webpack://_N_E/./src/hello.tsx => ./src/hello.tsx
* webpack://./src/hello.tsx => ./src/hello.tsx * webpack://./src/hello.tsx => ./src/hello.tsx
* webpack:///./src/hello.tsx => ./src/hello.tsx * webpack:///./src/hello.tsx => ./src/hello.tsx
......
...@@ -9,26 +9,6 @@ describe('webpack-module-path', () => { ...@@ -9,26 +9,6 @@ describe('webpack-module-path', () => {
expect( expect(
isWebpackInternalResource('webpack-internal:///./src/hello.tsx') isWebpackInternalResource('webpack-internal:///./src/hello.tsx')
).toBe(true) ).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(rsc)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42'
)
).toBe(true)
expect(
isWebpackInternalResource(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42dc'
)
).toBe(true)
expect(isWebpackInternalResource('webpack://_N_E/./src/hello.tsx')).toBe( expect(isWebpackInternalResource('webpack://_N_E/./src/hello.tsx')).toBe(
true true
) )
...@@ -47,31 +27,6 @@ describe('webpack-module-path', () => { ...@@ -47,31 +27,6 @@ describe('webpack-module-path', () => {
expect(formatFrameSourceFile('webpack-internal:///./src/hello.tsx')).toBe( expect(formatFrameSourceFile('webpack-internal:///./src/hello.tsx')).toBe(
'./src/hello.tsx' './src/hello.tsx'
) )
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(rsc)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42?0'
)
).toBe('./src/hello.tsx')
expect(
formatFrameSourceFile(
'rsc://React/Server/webpack:///(app-pages-browser)/./src/hello.tsx?42dc'
)
).toBe('./src/hello.tsx')
expect(formatFrameSourceFile('webpack://_N_E/./src/hello.tsx')).toBe( expect(formatFrameSourceFile('webpack://_N_E/./src/hello.tsx')).toBe(
'./src/hello.tsx' './src/hello.tsx'
) )
......
const replacementRegExes = [ const replacementRegExes = [
/^(rsc:\/\/React\/[^/]+\/)/,
/^webpack-internal:\/\/\/(\([\w-]+\)\/)?/, /^webpack-internal:\/\/\/(\([\w-]+\)\/)?/,
/^(webpack:\/\/\/|webpack:\/\/(_N_E\/)?)(\([\w-]+\)\/)?/, /^(webpack:\/\/\/|webpack:\/\/(_N_E\/)?)(\([\w-]+\)\/)?/,
/\?\w+(\?\d+)?$/, // React replay error query param, .e.g. ?c69d?0, ?c69d
/\?\d+$/, // React's fakeFunctionIdx query param
] ]
export function isWebpackInternalResource(file: string) { export function isWebpackInternalResource(file: string) {
...@@ -20,8 +17,6 @@ export function isWebpackInternalResource(file: string) { ...@@ -20,8 +17,6 @@ export function isWebpackInternalResource(file: string) {
* Format the webpack internal id to original file path * Format the webpack internal id to original file path
* *
* webpack-internal:///./src/hello.tsx => ./src/hello.tsx * webpack-internal:///./src/hello.tsx => ./src/hello.tsx
* rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => ./src/hello.tsx
* rsc://React/Server/webpack:///app/indirection.tsx?14cb?0 => app/indirection.tsx
* webpack://_N_E/./src/hello.tsx => ./src/hello.tsx * webpack://_N_E/./src/hello.tsx => ./src/hello.tsx
* webpack://./src/hello.tsx => ./src/hello.tsx * webpack://./src/hello.tsx => ./src/hello.tsx
* webpack:///./src/hello.tsx => ./src/hello.tsx * webpack:///./src/hello.tsx => ./src/hello.tsx
......
(()=>{"use strict";if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:true});var n="<unknown>";function parse(e){var r=e.split("\n");return r.reduce((function(e,r){var n=parseChrome(r)||parseWinjs(r)||parseGecko(r)||parseNode(r)||parseJSC(r);if(n){e.push(n)}return e}),[])}var a=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;var l=/\((\S*)(?::(\d+))(?::(\d+))\)/;function parseChrome(e){var r=a.exec(e);if(!r){return null}var u=r[2]&&r[2].indexOf("native")===0;var t=r[2]&&r[2].indexOf("eval")===0;var i=l.exec(r[2]);if(t&&i!=null){r[2]=i[1];r[3]=i[2];r[4]=i[3]}return{file:!u?r[2]:null,methodName:r[1]||n,arguments:u?[r[2]]:[],lineNumber:r[3]?+r[3]:null,column:r[4]?+r[4]:null}}var u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseWinjs(e){var r=u.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}var t=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;var i=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function parseGecko(e){var r=t.exec(e);if(!r){return null}var a=r[3]&&r[3].indexOf(" > eval")>-1;var l=i.exec(r[3]);if(a&&l!=null){r[3]=l[1];r[4]=l[2];r[5]=null}return{file:r[3],methodName:r[1]||n,arguments:r[2]?r[2].split(","):[],lineNumber:r[4]?+r[4]:null,column:r[5]?+r[5]:null}}var s=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;function parseJSC(e){var r=s.exec(e);if(!r){return null}return{file:r[3],methodName:r[1]||n,arguments:[],lineNumber:+r[4],column:r[5]?+r[5]:null}}var o=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseNode(e){var r=o.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}r.parse=parse})();module.exports=e})(); (()=>{"use strict";if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:true});var n="<unknown>";function parse(e){var r=e.split("\n");return r.reduce((function(e,r){var n=parseChrome(r)||parseWinjs(r)||parseGecko(r)||parseNode(r)||parseJSC(r);if(n){e.push(n)}return e}),[])}var a=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|webpack-internal|rsc|turbopack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;var l=/\((\S*)(?::(\d+))(?::(\d+))\)/;function parseChrome(e){var r=a.exec(e);if(!r){return null}var u=r[2]&&r[2].indexOf("native")===0;var t=r[2]&&r[2].indexOf("eval")===0;var i=l.exec(r[2]);if(t&&i!=null){r[2]=i[1];r[3]=i[2];r[4]=i[3]}return{file:!u?r[2]:null,methodName:r[1]||n,arguments:u?[r[2]]:[],lineNumber:r[3]?+r[3]:null,column:r[4]?+r[4]:null}}var u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|webpack-internal|rsc|turbopack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseWinjs(e){var r=u.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}var t=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|webpack-internal|rsc|turbopack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;var i=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function parseGecko(e){var r=t.exec(e);if(!r){return null}var a=r[3]&&r[3].indexOf(" > eval")>-1;var l=i.exec(r[3]);if(a&&l!=null){r[3]=l[1];r[4]=l[2];r[5]=null}return{file:r[3],methodName:r[1]||n,arguments:r[2]?r[2].split(","):[],lineNumber:r[4]?+r[4]:null,column:r[5]?+r[5]:null}}var s=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;function parseJSC(e){var r=s.exec(e);if(!r){return null}return{file:r[3],methodName:r[1]||n,arguments:[],lineNumber:+r[4],column:r[5]?+r[5]:null}}var c=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseNode(e){var r=c.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}r.parse=parse})();module.exports=e})();
\ No newline at end of file \ No newline at end of file
diff --git a/dist/stack-trace-parser.cjs.js b/dist/stack-trace-parser.cjs.js
index 50c63025c622ebe479e07544bd796c2d3922d4b8..db08766b67b9ca1bd48a27120a3ecfd1250aa768 100644
--- a/dist/stack-trace-parser.cjs.js
+++ b/dist/stack-trace-parser.cjs.js
@@ -20,7 +20,7 @@ function parse(stackString) {
return stack;
}, []);
}
-var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
+var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|webpack-internal|rsc|turbopack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
function parseChrome(line) {
@@ -54,7 +54,7 @@ function parseChrome(line) {
};
}
-var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
+var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|webpack-internal|rsc|turbopack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
function parseWinjs(line) {
var parts = winjsRe.exec(line);
@@ -72,7 +72,7 @@ function parseWinjs(line) {
};
}
-var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
+var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|webpack-internal|rsc|turbopack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
function parseGecko(line) {
...@@ -25,6 +25,9 @@ patchedDependencies: ...@@ -25,6 +25,9 @@ patchedDependencies:
'@storybook/react@8.5.2': '@storybook/react@8.5.2':
hash: 3vtnbaj5dhujyrhznezprlo624 hash: 3vtnbaj5dhujyrhznezprlo624
path: patches/@storybook__react@8.5.2.patch path: patches/@storybook__react@8.5.2.patch
stacktrace-parser@0.1.10:
hash: misknddihoqkqinipod62zbcj4
path: patches/stacktrace-parser@0.1.10.patch
webpack-sources@3.2.3: webpack-sources@3.2.3:
hash: jbynf5dc46ambamq3wuyho6hkq hash: jbynf5dc46ambamq3wuyho6hkq
path: patches/webpack-sources@3.2.3.patch path: patches/webpack-sources@3.2.3.patch
...@@ -1445,7 +1448,7 @@ importers: ...@@ -1445,7 +1448,7 @@ importers:
version: source-map@0.8.0-beta.0 version: source-map@0.8.0-beta.0
stacktrace-parser: stacktrace-parser:
specifier: 0.1.10 specifier: 0.1.10
version: 0.1.10 version: 0.1.10(patch_hash=misknddihoqkqinipod62zbcj4)
storybook: storybook:
specifier: 8.5.2 specifier: 8.5.2
version: 8.5.2(prettier@3.3.3) version: 8.5.2(prettier@3.3.3)
...@@ -33548,7 +33551,7 @@ snapshots: ...@@ -33548,7 +33551,7 @@ snapshots:
stackback@0.0.2: {} stackback@0.0.2: {}
stacktrace-parser@0.1.10: stacktrace-parser@0.1.10(patch_hash=misknddihoqkqinipod62zbcj4):
dependencies: dependencies:
type-fest: 0.7.1 type-fest: 0.7.1
...@@ -98,15 +98,11 @@ describe('non-root-project-monorepo', () => { ...@@ -98,15 +98,11 @@ describe('non-root-project-monorepo', () => {
if (isTurbopack) { if (isTurbopack) {
// TODO the function name should be hidden // TODO the function name should be hidden
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"app/source-maps-rsc/page.tsx (13:28) @ innerArrowFunction "app/separate-file.ts (1:7) @ [project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript)
11 | } > 1 | throw new Error('Expected error')
12 | | ^
> 13 | const innerArrowFunction = () => { 2 |"
| ^
14 | require('../separate-file')
15 | }
16 |"
`) `)
// TODO stacktrace-parser breaks in some cases with the rsc:// protocol // TODO stacktrace-parser breaks in some cases with the rsc:// protocol
expect( expect(
...@@ -115,8 +111,8 @@ describe('non-root-project-monorepo', () => { ...@@ -115,8 +111,8 @@ describe('non-root-project-monorepo', () => {
'/apps_web_XXXXXX._.js ' '/apps_web_XXXXXX._.js '
) )
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"<unknown> "[project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript)
[project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript) (rsc://React/Server/file://<full-path>/apps/web/.next/server/chunks/ssr/apps_web_XXXXXX._.js (7:7) app/separate-file.ts (1:7)
innerArrowFunction innerArrowFunction
app/source-maps-rsc/page.tsx (13:28) app/source-maps-rsc/page.tsx (13:28)
innerFunction innerFunction
...@@ -134,14 +130,15 @@ describe('non-root-project-monorepo', () => { ...@@ -134,14 +130,15 @@ describe('non-root-project-monorepo', () => {
2 |" 2 |"
`) `)
// TODO webpack runtime code shouldn't be included in stack trace // TODO webpack runtime code shouldn't be included in stack trace
// TODO(veil): https://linear.app/vercel/issue/NDX-677
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"eval "eval
app/separate-file.ts (1:11) app/separate-file.ts (1:11)
<unknown> <unknown>
rsc)/./app/separate-file.ts (rsc://React/Server/file://<full-path>/apps/web/.next/server/app/source-maps-rsc/page.js rsc)/./app/separate-file.ts (rsc://React/Server/file://<full-path>/apps/web/.next/server/app/source-maps-rsc/page.js?3 (149:1)
__webpack_require__ __webpack_require__
file://<full-path>/apps/web/.next/server/webpack-runtime.js rsc:/Server/file://<full-path>/apps/web/.next/server/webpack-runtime.js (33:42)
innerArrowFunction innerArrowFunction
app/source-maps-rsc/page.tsx (14:3) app/source-maps-rsc/page.tsx (14:3)
innerFunction innerFunction
......
...@@ -140,7 +140,7 @@ describe('use-cache-close-over-function', () => { ...@@ -140,7 +140,7 @@ describe('use-cache-close-over-function', () => {
'\n at createCachedFn (app/server/page.tsx:6:2)' + '\n at createCachedFn (app/server/page.tsx:6:2)' +
'\n at eval (app/server/page.tsx:12:23)' + '\n at eval (app/server/page.tsx:12:23)' +
// TODO(veil): Should be source-mapped. // TODO(veil): Should be source-mapped.
'\n at (rsc)' '\n at <unknown> (rsc)'
) )
expect(cliOutput).toContain( expect(cliOutput).toContain(
'' + '' +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment