Skip to content

fix(node): Mark stack frames with url protocol as in-app frames #8008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 3, 2023
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);
});
});