-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(core): Prevent infinite recursion when event processor throws #19110
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(core): Prevent infinite recursion when event processor throws #19110
Conversation
f0cde98 to
f420e5a
Compare
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.
Pull request overview
This PR fixes a critical bug where event processors that throw on all events cause infinite recursion, resulting in silent event loss. The fix skips event processors for internal exception events (marked with hint.data.__sentry__ = true) to break the recursion cycle, similar to how beforeSend is already skipped for these events.
Changes:
- Modified
prepareEvent.tsto detect internal exceptions and skip event processors for them - Added a test to verify that a client-level processor that always throws only runs once
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/utils/prepareEvent.ts | Added logic to skip event processors for internal exceptions (marked with __sentry__ flag) to prevent infinite recursion |
| packages/core/test/lib/client.test.ts | Added test to verify that a processor throwing on all events doesn't cause infinite recursion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Lms24
left a comment
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.
Sounds reasonable, good fix!
Codecov Results 📊✅ 146 passed | Total: 146 | Pass Rate: 100% | Execution Time: 6m 9s All tests are passing successfully. Generated by Codecov Action |
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
When an event processor throws an error, the SDK calls
captureExceptionto report it withhint.data.__sentry__ = true. However, this new event still ran through all event processors, causing infinite recursion if the processor throws on every event.I'm not sure what's the best way to resolve this, I had a couple of ideas:
prepareEvent().I went with (2) because it is consistent with how
beforeSendis already skipped for these events. The processor error is still captured and sent to Sentry, but it bypasses event processors to break the recursion.Fixes #19108