-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: split childProcess integration into childProcess and worker integrations #22885
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
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 |
|---|---|---|
|
|
@@ -178,6 +178,7 @@ export { metrics, withStreamedSpan } from '@sentry/core'; | |
| export * as logger from './logs/exports'; | ||
|
|
||
| export { childProcessIntegration } from './integrations/childProcess'; | ||
| export { workerIntegration } from './integrations/workerIntegration'; | ||
|
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. Bun export check missing ignoreMedium Severity
Reviewed by Cursor Bugbot for commit 26c387c. Configure here. |
||
| export { consoleIntegration } from './integrations/console'; | ||
| export { nodeContextIntegration } from './integrations/context'; | ||
| export { contextLinesIntegration } from './integrations/contextlines'; | ||
|
|
||
| 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 testsMedium Severity
Triggered by project rule: PR Review Guidelines for Cursor Bot Reviewed by Cursor Bugbot for commit 26c387c. 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.
Missing Astro workerIntegration export
Medium Severity
workerIntegrationis exported from@sentry/node,@sentry/aws-serverless, and@sentry/google-cloud-serverless, but@sentry/astrostill only re-exportschildProcessIntegration. Astro users cannot access the new API, and the consistent-exports check will fail for@sentry/astro.Reviewed by Cursor Bugbot for commit 26c387c. Configure here.