diff --git a/packages/utils/src/node-stack-trace.ts b/packages/utils/src/node-stack-trace.ts index 7797eb327bbe..00b02b0fee35 100644 --- a/packages/utils/src/node-stack-trace.ts +++ b/packages/utils/src/node-stack-trace.ts @@ -85,7 +85,16 @@ export function node(getModule?: GetModuleFn): StackLineParserFn { } const isInternal = - isNative || (filename && !filename.startsWith('/') && !filename.startsWith('.') && !filename.includes(':\\')); + isNative || + (filename && + // It's not internal if it's an absolute linux path + !filename.startsWith('/') && + // It's not internal if it's an absolute windows path + !filename.includes(':\\') && + // It's not internal if the path is starting with a dot + !filename.startsWith('.') && + // It's not internal if the frame has a protocol. In node, this is usually the case if the file got pre-processed with a bundler like webpack + !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//)); // Schema from: https://stackoverflow.com/a/3641782 // in_app is all that's not an internal Node function or a module within node_modules // note that isNative appears to return true even for node core libraries diff --git a/packages/utils/test/stacktrace.test.ts b/packages/utils/test/stacktrace.test.ts index 23257e507fb7..295fa282d906 100644 --- a/packages/utils/test/stacktrace.test.ts +++ b/packages/utils/test/stacktrace.test.ts @@ -264,4 +264,10 @@ describe('node', () => { in_app: true, }); }); + + it('should mark frames with protocols as in_app: true', () => { + const line = 'at Object. (app:///_next/server/pages/[error].js:10:20)'; + const result = node(line); + expect(result?.in_app).toBe(true); + }); });