Skip to content
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

feat(nextjs): Improve client stack traces #7097

Merged
merged 6 commits into from
Feb 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/nextjs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ function addClientIntegrations(options: BrowserOptions): void {
// Filename wasn't a properly formed URL, so there's nothing we can do
}

if (frame.filename && frame.filename.startsWith('app:///_next')) {
// We need to URI-decode the filename because Next.js has wildcard routes like "/users/[id].js" which show up as "/users/%5id%5.js" in Error stacktraces.
// The corresponding sources that Next.js generates have proper brackets so we also need proper brackets in the frame so that source map resolving works.
frame.filename = decodeURI(frame.filename);
}

if (
frame.filename &&
frame.filename.match(/^app:\/\/\/_next\/static\/chunks\/(main|main-app|polyfills|webpack)-[0-9a-f]{16}\.js$/)
) {
// We don't care about these frames. It's Next.js internal code.
frame.in_app = false;
}

return frame;
},
});
Expand Down