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
Copy link
Copy Markdown
Member

@mydea mydea commented May 26, 2026

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.

@mydea mydea self-assigned this May 26, 2026
@mydea mydea force-pushed the fn/remove-server-error-span branch from 53a9eb2 to c0f6a9e Compare May 26, 2026 13:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.27 kB - -
@sentry/browser - with treeshaking flags 25.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 flags 74.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/react 29.01 kB - -
@sentry/react (incl. Tracing) 47.49 kB -0.04% -15 B 🔽
@sentry/vue 32.19 kB - -
@sentry/vue (incl. Tracing) 47.12 kB -0.03% -14 B 🔽
@sentry/svelte 27.3 kB - -
CDN Bundle 29.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 - uncompressed 87.69 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.15 kB -0.03% -36 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 92.18 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.91 kB -0.03% -36 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 216.91 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.93 kB -0.02% -36 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.67 kB -0.02% -36 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.62 kB -0.02% -36 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.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/server 76.42 kB -0.04% -24 B 🔽
@sentry/core/browser 63.17 kB -0.04% -20 B 🔽
@sentry/node-core 62.25 kB -0.46% -287 B 🔽
@sentry/node 130.74 kB -0.25% -324 B 🔽
@sentry/node - without tracing 74.7 kB -0.37% -275 B 🔽
@sentry/aws-serverless 86.91 kB -0.34% -288 B 🔽
@sentry/cloudflare (withSentry) - minified 172.42 kB -0.57% -984 B 🔽
@sentry/cloudflare (withSentry) 430.68 kB -0.62% -2.65 kB 🔽

View base workflow run

@mydea mydea force-pushed the fn/remove-server-error-span branch from c0f6a9e to 163d0fa Compare May 27, 2026 06:30
@mydea mydea force-pushed the fn/remove-server-error-span branch from 648b60d to d1be7c0 Compare May 27, 2026 09:05
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 thread packages/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 owner May 27, 2026 10:33
@mydea mydea requested review from a team, JPeer264, Lms24 and andreiborza and removed request for a team, JPeer264 and andreiborza May 27, 2026 10:33
Copy link
Copy Markdown
Member

@Lms24 Lms24 left a comment

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
Member Author

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 develop May 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 free to 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