ref(nextjs): Remove next.js tracing escaping code - #22685
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 321bdca. Configure here.
| // to take, it can happen that the same thrown object gets caught in two different ways, and flagging it is a | ||
| // way to prevent it from actually being reported twice.) | ||
| const objectifiedErr = objectify(e); | ||
| }, |
There was a problem hiding this comment.
Duplicate API route transactions
High Severity
Removing dropNextjsRootContext and escapeNextjsTracing leaves Pages Router API requests with two root transactions. Next.js already emits a BaseServer.handleRequest span that Sentry enhances via enhanceHandleRequestRootSpan, and this wrapper still always starts another root with forceTransaction: true. Previously the Next.js span was dropped and the active span cleared so only the Sentry transaction remained. The edge wrapApiHandlerWithSentry avoids this by enhancing the existing root and starting a normal child span when one is active.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 321bdca. Configure here.
There was a problem hiding this comment.
Would be fine after this #18394
since we drop the startSpan call over there
There was a problem hiding this comment.
do we not have any tests that cover this 😅
There was a problem hiding this comment.
Nope, I will create a PR with that test that we can stack these two PRs on.
321bdca to
723570e
Compare
s1gr1d
left a comment
There was a problem hiding this comment.
As this only affects the pages router API routes, we should make sure that this is properly tested if it isn't already. Especially for duplicate/orphaned transactions (also the part that cursor mentioned)
d2d0c97 to
c236517
Compare
c236517 to
af6052f
Compare


It seems that everything is working as expected without this code, so likely this is no longer needed for the versions of next.js we support...?