-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(node): Fix local variables capturing for out-of-app frames #17545
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
Open
+320
−115
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d92b0a0
fix(node-core): Fix local variables capturing for out-of-app frames (...
JealousGx 7ca795c
fix(local-variables): Clean up function assignment and fix syntax in ...
JealousGx 5323928
fix(local-variables): Refine condition for skipping out-of-app frames...
JealousGx 7fb4542
fix(node-core): Fix race condition in local variables integration
JealousGx 662ab6d
Merge branch 'develop' into fix/local-variables-12588
JealousGx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
packages/node-core/src/integrations/local-variables/test-helpers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// // TEST-ONLY: allow tests to access the cache | ||
|
||
import type { LRUMap } from '@sentry/core'; | ||
import type { FrameVariables } from './common'; | ||
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 would prefer if we didn't do this (and not add unit tests). Instead I'd like us to add tests under our node integration tests to validate this: https://github.com/getsentry/sentry-javascript/tree/develop/dev-packages/node-integration-tests/suites/public-api/LocalVariables |
||
|
||
/** | ||
* Provides test helper methods for interacting with the local variables cache. | ||
* These methods are intended for use in unit tests to inspect and manipulate | ||
* the internal cache of frame variables used by the LocalVariables integration. | ||
* | ||
* @param cachedFrames - The LRUMap instance storing cached frame variables. | ||
* @returns An object containing helper methods for cache inspection and mutation. | ||
*/ | ||
export function localVariablesTestHelperMethods(cachedFrames: LRUMap<string, FrameVariables[]>): { | ||
_getCachedFramesCount: () => number; | ||
_getFirstCachedFrame: () => FrameVariables[] | undefined; | ||
_setCachedFrame: (hash: string, frames: FrameVariables[]) => void; | ||
} { | ||
/** | ||
* Returns the number of entries in the local variables cache. | ||
*/ | ||
function _getCachedFramesCount(): number { | ||
return cachedFrames.size; | ||
} | ||
|
||
/** | ||
* Returns the first set of cached frame variables, or undefined if the cache is empty. | ||
*/ | ||
function _getFirstCachedFrame(): FrameVariables[] | undefined { | ||
return cachedFrames.values()[0]; | ||
} | ||
|
||
/** | ||
* Sets the cached frame variables for a given stack hash. | ||
* | ||
* @param hash - The stack hash to associate with the cached frames. | ||
* @param frames - The frame variables to cache. | ||
*/ | ||
function _setCachedFrame(hash: string, frames: FrameVariables[]): void { | ||
cachedFrames.set(hash, frames); | ||
} | ||
|
||
return { | ||
_getCachedFramesCount, | ||
_getFirstCachedFrame, | ||
_setCachedFrame, | ||
}; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.