Skip to content
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

test: Add tests to demonstrate withScope data loss for uncaught errors #11204

Merged
merged 6 commits into from Mar 21, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 19, 2024

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 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.

@Lms24 Lms24 changed the title test: Add tests to demonstrate withScope data loss [ignore] test: Add tests to demonstrate withScope data loss Mar 19, 2024
Copy link
Contributor

github-actions bot commented Mar 19, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) 80.73 KB (added)
@sentry/browser (incl. Tracing, Replay) 72.08 KB (added)
@sentry/browser (incl. Tracing, Replay with Canvas) 75.88 KB (added)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 65.64 KB (added)
@sentry/browser (incl. Tracing) 36.68 KB (added)
@sentry/browser (incl. browserTracingIntegration) 36.68 KB (added)
@sentry/browser (incl. feedbackIntegration) 31.35 KB (added)
@sentry/browser (incl. feedbackModalIntegration) 31.47 KB (added)
@sentry/browser (incl. feedbackScreenshotIntegration) 31.48 KB (added)
@sentry/browser (incl. sendFeedback) 27.43 KB (added)
@sentry/browser 22.6 KB (added)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.07 KB (added)
CDN Bundle (incl. Tracing, Replay) 69.92 KB (added)
CDN Bundle (incl. Tracing) 36.27 KB (added)
CDN Bundle 23.97 KB (added)
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.58 KB (added)
CDN Bundle (incl. Tracing) - uncompressed 109.53 KB (added)
CDN Bundle - uncompressed 71 KB (added)
@sentry/react (incl. Tracing, Replay) 72.07 KB (added)
@sentry/react 22.63 KB (added)

@Lms24 Lms24 force-pushed the lms/test-withscope-error-throw branch from 270c6b6 to 6673bc0 Compare March 21, 2024 10:39
@Lms24 Lms24 changed the title [ignore] test: Add tests to demonstrate withScope data loss test: Add tests to demonstrate withScope data loss for uncaught errors Mar 21, 2024
@Lms24 Lms24 marked this pull request as ready for review March 21, 2024 12:14
@Lms24 Lms24 requested review from a team, lforst and AbhiPrasad and removed request for a team March 21, 2024 12:14
@Lms24 Lms24 merged commit aa76951 into develop Mar 21, 2024
80 checks passed
@Lms24 Lms24 deleted the lms/test-withscope-error-throw branch March 21, 2024 15:20
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants