test: Add tests to demonstrate withScope data loss for uncaught errors#11204
Merged
test: Add tests to demonstrate withScope data loss for uncaught errors#11204
withScope data loss for uncaught errors#11204Conversation
Contributor
size-limit report 📦
|
270c6b6 to
6673bc0
Compare
withScope data loss for uncaught errors
lforst
approved these changes
Mar 21, 2024
cadesalaberry
pushed a commit
to cadesalaberry/sentry-javascript
that referenced
this pull request
Apr 19, 2024
…ors (getsentry#11204) This PR adds integration tests (browser and node) to demonstrate the current behavior around loosing scope data when a thrown error is caught by global handlers "outside" the lifetime of the throw origin's scope. This occurs specifically within the `withScope` API where the scope is popped if an error is caught but then the error is rethrown to be caught by handlers down the line.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds integration tests (browser and node) to demonstrate the current behavior around loosing scope data when a thrown error is caught by global handlers "outside" the lifetime of the throw origin's scope. This occurs specifically within the
withScopeAPI where the scope is popped if an error is caught but then the error is rethrown to be caught by handlers down the line.This behaviour was reported in #11133 and investigated across SDKs in getsentry/sentry-python#2857. For now it seems that general consensus is that this is expected behaviour.
So in an effort to be aware of the implications of this behavior (i.e. somewhat unexpected scope data loss), let's add these tests.
Side note: In the vast majority of our integration tests, we call
captureException; Hence, we rarely test how unhandled errors caught by our global error handler instrumentations behave (or potentially differ from a manually captured error). We should capture errors more diversely in the future.