-
-
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): Remove ambiguity and race conditions when matching local variables to exceptions #13501
Changes from all commits
d6d0462
7ac938f
46a057e
87d5d75
efacd0a
306dca7
069d6f2
ac543cf
efbad10
efdbd45
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,6 +1,6 @@ | ||
import type { Debugger, InspectorNotification, Runtime, Session } from 'node:inspector'; | ||
import { defineIntegration, getClient } from '@sentry/core'; | ||
import type { Event, Exception, IntegrationFn, StackParser } from '@sentry/types'; | ||
import type { Event, Exception, IntegrationFn, StackFrame, StackParser } from '@sentry/types'; | ||
import { LRUMap, logger } from '@sentry/utils'; | ||
|
||
import { NODE_MAJOR } from '../../nodeVersion'; | ||
|
@@ -12,7 +12,29 @@ import type { | |
RateLimitIncrement, | ||
Variables, | ||
} from './common'; | ||
import { createRateLimiter, functionNamesMatch, hashFrames, hashFromStack } from './common'; | ||
import { createRateLimiter, functionNamesMatch } from './common'; | ||
|
||
/** Creates a unique hash from stack frames */ | ||
export function hashFrames(frames: StackFrame[] | undefined): string | undefined { | ||
if (frames === undefined) { | ||
return; | ||
} | ||
|
||
// Only hash the 10 most recent frames (ie. the last 10) | ||
return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); | ||
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. I wonder if we should filter out system frames here, so basically either
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. This code is for the sync debugger has simply been copied from |
||
} | ||
|
||
/** | ||
* We use the stack parser to create a unique hash from the exception stack trace | ||
* This is used to lookup vars when the exception passes through the event processor | ||
*/ | ||
export function hashFromStack(stackParser: StackParser, stack: string | undefined): string | undefined { | ||
if (stack === undefined) { | ||
return undefined; | ||
} | ||
|
||
return hashFrames(stackParser(stack, 1)); | ||
} | ||
|
||
type OnPauseEvent = InspectorNotification<Debugger.PausedEventDataType>; | ||
export interface DebugSession { | ||
|
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.
in both here and the worker, is it worth adding some kind of debug logging for when the sdk is in debug mode?
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.
I think we can validate it pretty easily by inspecting the event in
beforeSend
, so I think we don't explicitly need logging for every event, but @timfish if you think it's a good idea go for it.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 also the discussion over whether some of our logging here should be behind
debug: true
or regularconsole.*
. If we hit rate limiting maybe this should always be logged rather than only when debug is enabled? Users are unlikely to have debug logging enabled in production but it's likely useful to know when you're hitting rate limiting.