-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(node): Include debug_meta
with ANR events
#14203
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import * as diagnosticsChannel from 'node:diagnostics_channel'; | ||
import { Worker } from 'node:worker_threads'; | ||
import { defineIntegration, getCurrentScope, getGlobalScope, getIsolationScope, mergeScopeData } from '@sentry/core'; | ||
import type { Contexts, Event, EventHint, Integration, IntegrationFn, ScopeData } from '@sentry/types'; | ||
import { GLOBAL_OBJ, logger } from '@sentry/utils'; | ||
import { GLOBAL_OBJ, getFilenameToDebugIdMap, logger } from '@sentry/utils'; | ||
import { NODE_VERSION } from '../../nodeVersion'; | ||
import type { NodeClient } from '../../sdk/client'; | ||
import type { AnrIntegrationOptions, WorkerStartData } from './common'; | ||
|
@@ -100,6 +101,13 @@ type AnrReturn = (options?: Partial<AnrIntegrationOptions>) => Integration & Anr | |
|
||
export const anrIntegration = defineIntegration(_anrIntegration) as AnrReturn; | ||
|
||
function onModuleLoad(callback: () => void): void { | ||
// eslint-disable-next-line deprecation/deprecation | ||
diagnosticsChannel.channel('module.require.end').subscribe(() => callback()); | ||
// eslint-disable-next-line deprecation/deprecation | ||
diagnosticsChannel.channel('module.import.asyncEnd').subscribe(() => callback()); | ||
} | ||
|
||
/** | ||
* Starts the ANR worker thread | ||
* | ||
|
@@ -153,6 +161,12 @@ async function _startWorker( | |
} | ||
} | ||
|
||
let debugImages: Record<string, string> = getFilenameToDebugIdMap(initOptions.stackParser); | ||
|
||
onModuleLoad(() => { | ||
debugImages = getFilenameToDebugIdMap(initOptions.stackParser); | ||
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. Isn't this potentially called every 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. We could debounce the If 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. Alright let's proceed for now, we should re-visit this though. |
||
}); | ||
|
||
const worker = new Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), { | ||
workerData: options, | ||
// We don't want any Node args to be passed to the worker | ||
|
@@ -171,7 +185,7 @@ async function _startWorker( | |
// serialized without making it a SerializedSession | ||
const session = currentSession ? { ...currentSession, toJSON: undefined } : undefined; | ||
// message the worker to tell it the main event loop is still running | ||
worker.postMessage({ session }); | ||
worker.postMessage({ session, debugImages }); | ||
} catch (_) { | ||
// | ||
} | ||
|
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.
Why are these deprecated?
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.
There's a new API in
diagnostics_channel
to subscribe to a channel but we need to support older Node versions where this doesn't exist so we rely on the deprecated API.