-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(node): Include global scope for eventLoopBlockIntegration
#20108
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 |
|---|---|---|
|
|
@@ -8,8 +8,18 @@ import type { | |
| EventHint, | ||
| Integration, | ||
| IntegrationFn, | ||
| ScopeData, | ||
| } from '@sentry/core'; | ||
| import { | ||
| debug, | ||
| defineIntegration, | ||
| getClient, | ||
| getCurrentScope, | ||
| getFilenameToDebugIdMap, | ||
| getGlobalScope, | ||
| getIsolationScope, | ||
| mergeScopeData, | ||
| } from '@sentry/core'; | ||
| import { debug, defineIntegration, getClient, getFilenameToDebugIdMap, getIsolationScope } from '@sentry/core'; | ||
| import type { NodeClient } from '@sentry/node'; | ||
| import { registerThread, threadPoll } from '@sentry-internal/node-native-stacktrace'; | ||
| import type { ThreadBlockedIntegrationOptions, WorkerStartData } from './common'; | ||
|
|
@@ -37,6 +47,13 @@ async function getContexts(client: NodeClient): Promise<Contexts> { | |
| return event?.contexts || {}; | ||
| } | ||
|
|
||
| function getLocalScopeData(): ScopeData { | ||
| const globalScope = getGlobalScope().getScopeData(); | ||
| const currentScope = getCurrentScope().getScopeData(); | ||
| mergeScopeData(globalScope, currentScope); | ||
| return globalScope; | ||
| } | ||
|
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. ScopeData with non-serializable fields passed to native moduleMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 0742247. Configure here.
Collaborator
Author
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.
|
||
|
|
||
| type IntegrationInternal = { start: () => void; stop: () => void }; | ||
|
|
||
| function poll(enabled: boolean, clientOptions: ClientOptions): void { | ||
|
|
@@ -45,8 +62,9 @@ function poll(enabled: boolean, clientOptions: ClientOptions): void { | |
| // We need to copy the session object and remove the toJSON method so it can be sent to the worker | ||
| // serialized without making it a SerializedSession | ||
| const session = currentSession ? { ...currentSession, toJSON: undefined } : undefined; | ||
| const scope = getLocalScopeData(); | ||
| // message the worker to tell it the main event loop is still running | ||
| threadPoll(enabled, { session, debugImages: getFilenameToDebugIdMap(clientOptions.stackParser) }); | ||
| threadPoll(enabled, { session, scope, debugImages: getFilenameToDebugIdMap(clientOptions.stackParser) }); | ||
| } catch { | ||
| // we ignore all errors | ||
| } | ||
|
|
||


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.
Is this required of can we just sync the global scope?
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.
this seems reasonable to me? ideally I guess it should be global + isolation + current scope, not sure if/how isolation scope is handled here generally :)
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.
Isolation scope is captured via native code from the AsyncLocalStorage!