Skip to content

feat(node): Capture exceptions from worker_threads #15105

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

Merged
merged 14 commits into from
Jan 21, 2025

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Jan 21, 2025

Updates the childProcessIntegration to capture worker_threads errors (including their stack traces) rather than capturing a breadcrumb.

This features is enabled by default and can be disabled by setting the captureWorkerErrors option to false:

Sentry.init({
  dsn: 'https://public@dsn.ingest.sentry.io/1337',
  integrations: [Sentry.childProcessIntegration({ captureWorkerErrors: false })],
});

When captureWorkerErrors: false, a breadcrumb will be captured instead.

This PR also adds more integration tests for the childProcessIntegration.

@timfish timfish marked this pull request as draft January 21, 2025 09:52
@timfish timfish changed the title feat(node): Capture exceptions from worker_threads test(node): childProcessIntegration Tests Jan 21, 2025
@timfish timfish changed the title test(node): childProcessIntegration Tests feat(node): Capture exceptions from worker_threads Jan 21, 2025
Copy link
Contributor

github-actions bot commented Jan 21, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.98 KB - -
@sentry/browser - with treeshaking flags 22.87 KB - -
@sentry/browser (incl. Tracing) 35.68 KB - -
@sentry/browser (incl. Tracing, Replay) 72.47 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.03 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 76.72 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 88.74 KB - -
@sentry/browser (incl. Feedback) 39.19 KB - -
@sentry/browser (incl. sendFeedback) 27.61 KB - -
@sentry/browser (incl. FeedbackAsync) 32.37 KB - -
@sentry/react 25.66 KB - -
@sentry/react (incl. Tracing) 38.46 KB - -
@sentry/vue 27.04 KB - -
@sentry/vue (incl. Tracing) 37.43 KB - -
@sentry/svelte 23.11 KB - -
CDN Bundle 24.36 KB - -
CDN Bundle (incl. Tracing) 36 KB - -
CDN Bundle (incl. Tracing, Replay) 70.64 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 75.79 KB - -
CDN Bundle - uncompressed 71.16 KB - -
CDN Bundle (incl. Tracing) - uncompressed 106.82 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.67 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.2 KB - -
@sentry/nextjs (client) 38.58 KB - -
@sentry/sveltekit (client) 36.21 KB - -
@sentry/node 156.21 KB +0.03% +36 B 🔺
@sentry/node - without tracing 97.36 KB +0.04% +35 B 🔺
@sentry/aws-serverless 106.77 KB +0.04% +40 B 🔺

View base workflow run

@timfish timfish marked this pull request as ready for review January 21, 2025 11:06
@timfish timfish requested a review from AbhiPrasad January 21, 2025 14:17
@timfish timfish requested review from lforst and Lms24 January 21, 2025 14:27
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Do the events captured from worker_threads get the correct trace id attached to them?

I wonder if we should be propagating the trace context to the worker threads scope with this integration as well 🤔

@timfish
Copy link
Collaborator Author

timfish commented Jan 21, 2025

Currently this works even without Sentry running in the worker thread and because it uses captureException it will just use the main threads scope and trace context.

@AbhiPrasad AbhiPrasad merged commit a3cf458 into develop Jan 21, 2025
101 checks passed
@AbhiPrasad AbhiPrasad deleted the timfish/feat/child-process-extra branch January 21, 2025 17:54
@AbhiPrasad
Copy link
Member

Let's open a draft PR for this in the docs, we can only merge it in when we release v9 though.

I don't think we should backport this, we can make it a new feature for v9+

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