Skip to content

Conversation

@JPeer264
Copy link
Member

@JPeer264 JPeer264 commented Jan 5, 2026

closes #18592
closes JS-1347

The onUncaughtException integration triggered for errors inside workers, which caused a wrong error code overall. Since we already have a Child Process integration which handles errors it would make most sense to disable the onUncaughtException integration entirely for workers.

Another option would also be to only ignore shouldApplyFatalHandlingLogic for workers, which was the main reason to exit the entire process, even though the error was handled - but I don't like this approach, since the child processes errors will be handled anyways in the other integration.

Interesting finding: When using --import or --require CLI flags, these are propagated to worker threads, so Sentry.init() runs twice: once in the main thread (isMainThread === true) and once in the worker (isMainThread === false). However, when using inline require() inside a file, it is NOT propagated to workers, so it initializes only once with isMainThread === true. This means the bug primarily manifests with ESM (--import) or when CJS uses --require (which may be less common).

The caught-worker-inline.js test always passes (inline require), while caught-worker.js with --require only passes after the fix is applied, demonstrating this behavior.

@JPeer264 JPeer264 requested review from Lms24 and timfish January 5, 2026 09:17
@linear
Copy link

linear bot commented Jan 5, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.84 kB - -
@sentry/browser - with treeshaking flags 23.34 kB - -
@sentry/browser (incl. Tracing) 41.62 kB - -
@sentry/browser (incl. Tracing, Profiling) 46.21 kB - -
@sentry/browser (incl. Tracing, Replay) 80.19 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.93 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.87 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 97.13 kB - -
@sentry/browser (incl. Feedback) 41.57 kB - -
@sentry/browser (incl. sendFeedback) 29.53 kB - -
@sentry/browser (incl. FeedbackAsync) 34.53 kB - -
@sentry/browser (incl. Metrics) 25.85 kB - -
@sentry/browser (incl. Logs) 26.07 kB - -
@sentry/browser (incl. Metrics & Logs) 26.82 kB - -
@sentry/react 26.58 kB - -
@sentry/react (incl. Tracing) 43.85 kB - -
@sentry/vue 29.3 kB - -
@sentry/vue (incl. Tracing) 43.44 kB - -
@sentry/svelte 24.86 kB - -
CDN Bundle 27.26 kB - -
CDN Bundle (incl. Tracing) 42.27 kB - -
CDN Bundle (incl. Tracing, Replay) 78.98 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 84.44 kB - -
CDN Bundle - uncompressed 80.02 kB - -
CDN Bundle (incl. Tracing) - uncompressed 125.45 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 241.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 254.78 kB - -
@sentry/nextjs (client) 46.21 kB - -
@sentry/sveltekit (client) 41.99 kB - -
@sentry/node-core 51.71 kB +0.04% +16 B 🔺
@sentry/node 161.63 kB +0.01% +15 B 🔺
@sentry/node - without tracing 93.14 kB +0.02% +17 B 🔺
@sentry/aws-serverless 108.65 kB +0.02% +15 B 🔺

View base workflow run

Copy link
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.

I have to admit, I was a bit confused about this change first, because I didn't know that childProcessIntegration also covers worker threads. To me, processes and threads are something different 😅 ... should we rename or split up the integration?

Anyway, the change itself looks reasonable to me. Thanks for fixing!

@timfish
Copy link
Collaborator

timfish commented Jan 5, 2026

Looks like it originally only supported child processes and then I added support for worker threads here #15105.

It would probably make sense to rename it!

@JPeer264
Copy link
Member Author

JPeer264 commented Jan 5, 2026

To me, processes and threads are something different 😅 ... should we rename or split up the integration?

It would probably make sense to rename it!

I created a ticket for it for further discussions: #18698

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,053 - 8,586 +5%
GET With Sentry 1,710 19% 1,602 +7%
GET With Sentry (error only) 6,149 68% 5,921 +4%
POST Baseline 1,178 - 1,174 +0%
POST With Sentry 589 50% 572 +3%
POST With Sentry (error only) 1,046 89% 1,015 +3%
MYSQL Baseline 3,281 - 3,167 +4%
MYSQL With Sentry 457 14% 405 +13%
MYSQL With Sentry (error only) 2,681 82% 2,609 +3%

View base workflow run

@JPeer264 JPeer264 merged commit 2a2e8cb into develop Jan 8, 2026
148 checks passed
@JPeer264 JPeer264 deleted the jp/worker-thread branch January 8, 2026 08:07
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.

Sentry changing worker thread error behavior

4 participants