Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/utils/src/node-stack-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/utils/test/stacktrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,10 @@ describe('node', () => {
in_app: true,
});
});

it('should mark frames with protocols as in_app: true', () => {
const line = 'at Object.<anonymous> (app:///_next/server/pages/[error].js:10:20)';
const result = node(line);
expect(result?.in_app).toBe(true);
});
});