Skip to content

ref(node): Stop using registerSpanErrorInstrumentation() on server - #21169

Merged
mydea merged 5 commits into
developfrom
fn/remove-server-error-span
May 27, 2026
Merged

ref(node): Stop using registerSpanErrorInstrumentation() on server#21169
mydea merged 5 commits into
developfrom
fn/remove-server-error-span

Conversation

@mydea

@mydeamydea commented May 26, 2026

Copy link
Copy Markdown
Member

I think this does nothing on node, because the implementation of this calls this under the hood:

addGlobalErrorInstrumentationHandler(errorCallback);addGlobalUnhandledRejectionInstrumentationHandler(errorCallback);

basically browser-only, using window.onerror. I believe this is handled specifically in node anyhow so should not be used/needed and allows us to streamline this a bit and potentially move this to a browser-only place eventually.

This also means we can remove the tag we put here, because this is actually not needed.

I adjusted a node-integration-test to verify this works there, both with using our own startSpan implementations (express uses this). With otel-native spans, it does not work, but it did not work before either - IMHO this is fine for the time being.

@mydeamydea self-assigned this May 26, 2026
@mydea
mydeaforce-pushed the fn/remove-server-error-span branch from 53a9eb2 to c0f6a9eCompareMay 26, 2026 13:29
@github-actions

github-actionsBot commented May 26, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.27 kB--
@sentry/browser - with treeshaking flags25.69 kB--
@sentry/browser (incl. Tracing)45.25 kB-0.04%-16 B 🔽
@sentry/browser (incl. Tracing + Span Streaming)47.49 kB-0.03%-14 B 🔽
@sentry/browser (incl. Tracing, Profiling)50.23 kB-0.04%-20 B 🔽
@sentry/browser (incl. Tracing, Replay)84.86 kB-0.02%-16 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.36 kB-0.03%-17 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas)89.57 kB-0.02%-16 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback)102.18 kB-0.02%-16 B 🔽
@sentry/browser (incl. Feedback)44.46 kB--
@sentry/browser (incl. sendFeedback)32.09 kB--
@sentry/browser (incl. FeedbackAsync)37.21 kB--
@sentry/browser (incl. Metrics)28.37 kB--
@sentry/browser (incl. Logs)28.59 kB--
@sentry/browser (incl. Metrics & Logs)29.29 kB--
@sentry/react29.01 kB--
@sentry/react (incl. Tracing)47.49 kB-0.04%-15 B 🔽
@sentry/vue32.19 kB--
@sentry/vue (incl. Tracing)47.12 kB-0.03%-14 B 🔽
@sentry/svelte27.3 kB--
CDN Bundle29.68 kB--
CDN Bundle (incl. Tracing)47.78 kB-0.05%-21 B 🔽
CDN Bundle (incl. Logs, Metrics)31.17 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.03 kB-0.04%-18 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics)70.48 kB--
CDN Bundle (incl. Tracing, Replay)85.28 kB-0.02%-17 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.43 kB-0.03%-19 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback)91.15 kB-0.02%-18 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.31 kB-0.03%-19 B 🔽
CDN Bundle - uncompressed87.69 kB--
CDN Bundle (incl. Tracing) - uncompressed144.15 kB-0.03%-36 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed92.18 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed147.91 kB-0.03%-36 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed216.91 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed262.93 kB-0.02%-36 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed266.67 kB-0.02%-36 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed276.62 kB-0.02%-36 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed280.36 kB-0.02%-36 B 🔽
@sentry/nextjs (client)49.98 kB-0.04%-16 B 🔽
@sentry/sveltekit (client)45.73 kB-0.04%-15 B 🔽
@sentry/core/server76.42 kB-0.04%-24 B 🔽
@sentry/core/browser63.17 kB-0.04%-20 B 🔽
@sentry/node-core62.25 kB-0.46%-287 B 🔽
@sentry/node130.74 kB-0.25%-324 B 🔽
@sentry/node - without tracing74.7 kB-0.37%-275 B 🔽
@sentry/aws-serverless86.91 kB-0.34%-288 B 🔽
@sentry/cloudflare (withSentry) - minified172.42 kB-0.57%-984 B 🔽
@sentry/cloudflare (withSentry)430.68 kB-0.62%-2.65 kB 🔽

View base workflow run

@mydea
mydeaforce-pushed the fn/remove-server-error-span branch from c0f6a9e to 163d0faCompareMay 27, 2026 06:30
@mydea
mydeaforce-pushed the fn/remove-server-error-span branch from 648b60d to d1be7c0CompareMay 27, 2026 09:05

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d1be7c0. Configure here.

Comment threadpackages/node-core/src/integrations/onuncaughtexception.ts
@mydea
mydea marked this pull request as ready for review May 27, 2026 10:33
@mydea
mydea requested a review from a team as a code ownerMay 27, 2026 10:33
@mydea
mydea requested review from a team, JPeer264, Lms24 and andreiborza and removed request for a team, JPeer264 and andreiborzaMay 27, 2026 10:33

@Lms24Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me, though I had one question/concern. But apart from that it seems like no tests fail and the tests added demonstrate unchanged behavior.

);
},
).length;
const userProvidedListenersCount = global.process.listeners('uncaughtException').filter(listener => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this change has me slightly suspicious because IIUC it implies that the registerSpanErrorInstrumentation() had an effect that we needed to skip here. Any idea why this might be? Could also just be a false flag and the tag condition just never made a difference...

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah also not sure, the code was here to handle the theoretical case where this would have worked but it hasn't - either it used to work differently back in the day, or it never worked - there was also not really test coverage for this as far as I can tell 😬

@mydea
mydea merged commit 5fe6aab into developMay 27, 2026
264 of 265 checks passed
@mydea
mydea deleted the fn/remove-server-error-span branch May 27, 2026 12:44
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@mydea@Lms24