-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: split childProcess integration into childProcess and worker integrations #22886
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type { Worker } from 'node:worker_threads'; | ||
| import * as diagnosticsChannel from 'node:diagnostics_channel'; | ||
| import { addBreadcrumb, captureException, defineIntegration, isObjectLike } from '@sentry/core'; | ||
|
|
||
| interface Options { | ||
| /** | ||
| * Whether to capture errors from worker threads. | ||
| * | ||
| * @default true | ||
| */ | ||
| captureWorkerErrors?: boolean; | ||
| } | ||
|
|
||
| const INTEGRATION_NAME = 'Worker' as const; | ||
|
|
||
| /** | ||
| * Capture breadcrumbs and events for worker threads. | ||
| */ | ||
| export const workerIntegration = defineIntegration((options: Options = {}) => { | ||
| return { | ||
| name: INTEGRATION_NAME, | ||
| setup() { | ||
| diagnosticsChannel.channel('worker_threads').subscribe((event: unknown) => { | ||
| if (isObjectLike(event) && 'worker' in event) { | ||
| captureWorkerThreadEvents(event.worker as Worker, options); | ||
| } | ||
| }); | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| function captureWorkerThreadEvents(worker: Worker, options: Options): void { | ||
| let threadId: number | undefined; | ||
|
|
||
| worker | ||
| .on('online', () => { | ||
| threadId = worker.threadId; | ||
| }) | ||
| .on('error', error => { | ||
| if (options.captureWorkerErrors !== false) { | ||
| captureException(error, { | ||
| mechanism: { type: 'auto.worker_thread', handled: false, data: { threadId: threadId !== undefined ? String(threadId) : undefined } }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stale worker mechanism in testsHigh Severity The worker error mechanism type changed to Triggered by project rule: PR Review Guidelines for Cursor Bot Reviewed by Cursor Bugbot for commit bab9d05. Configure here. |
||
| }); | ||
| } else { | ||
| addBreadcrumb({ | ||
| category: 'worker_thread', | ||
| message: `Worker thread errored with '${error.message}'`, | ||
| level: 'error', | ||
| data: { threadId }, | ||
| }); | ||
| } | ||
| }); | ||
| } | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete dependent package exports
Medium Severity
workerIntegrationis exported from@sentry/node, AWS, and Google Cloud, but not from@sentry/astro, which still manually re-exportschildProcessIntegration. The exports consistency check also still ignores onlychildProcessIntegrationfor Bun, so Astro and Bun will fail that E2E assertion.Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit bab9d05. Configure here.