Skip to content

Conversation

@logaretm
Copy link
Member

When an event processor throws an error, the SDK calls captureException to report it with hint.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:

  1. Mark an "event processor" as faulty and skip if an error is thrown from there by adding metadata in catch blocks.
  2. Outright skip event processors for internal exception events in prepareEvent().

I went with (2) because it is consistent with how beforeSend is 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

@linear
Copy link

linear bot commented Jan 30, 2026

@logaretm logaretm force-pushed the awad/js-1606-event-processor-errors-cause-silent-event-loss-via-infinite branch from f0cde98 to f420e5a Compare January 30, 2026 20:37
Copy link
Contributor

Copilot AI left a 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.ts to 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.

Copy link
Member

@Lms24 Lms24 left a 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!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

Codecov Results 📊

146 passed | Total: 146 | Pass Rate: 100% | Execution Time: 6m 9s

All tests are passing successfully.


Generated by Codecov Action

@github-actions
Copy link
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.43 kB +0.09% +22 B 🔺
@sentry/browser - with treeshaking flags 23.89 kB +0.09% +21 B 🔺
@sentry/browser (incl. Tracing) 42.23 kB +0.04% +14 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.88 kB +0.04% +16 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.86 kB +0.03% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.47 kB +0.03% +21 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.56 kB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.76 kB +0.03% +20 B 🔺
@sentry/browser (incl. Feedback) 42.15 kB +0.05% +20 B 🔺
@sentry/browser (incl. sendFeedback) 30.11 kB +0.08% +22 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.12 kB +0.07% +22 B 🔺
@sentry/browser (incl. Metrics) 26.54 kB +0.11% +27 B 🔺
@sentry/browser (incl. Logs) 26.69 kB +0.08% +21 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.35 kB +0.08% +20 B 🔺
@sentry/react 27.15 kB +0.07% +17 B 🔺
@sentry/react (incl. Tracing) 44.47 kB +0.04% +16 B 🔺
@sentry/vue 29.86 kB +0.06% +17 B 🔺
@sentry/vue (incl. Tracing) 44.03 kB +0.05% +18 B 🔺
@sentry/svelte 25.45 kB +0.1% +23 B 🔺
CDN Bundle 27.97 kB +0.08% +20 B 🔺
CDN Bundle (incl. Tracing) 43.01 kB +0.04% +15 B 🔺
CDN Bundle (incl. Logs, Metrics) 28.81 kB +0.07% +20 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 43.83 kB +0.04% +16 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 67.76 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.73 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.61 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.18 kB +0.03% +18 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.11 kB +0.02% +17 B 🔺
CDN Bundle - uncompressed 81.8 kB +0.06% +48 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.34 kB +0.04% +48 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 84.63 kB +0.06% +48 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.17 kB +0.04% +48 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.02 kB +0.03% +48 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 243.94 kB +0.02% +48 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 246.76 kB +0.02% +48 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 256.74 kB +0.02% +48 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 259.55 kB +0.02% +48 B 🔺
@sentry/nextjs (client) 46.82 kB +0.04% +18 B 🔺
@sentry/sveltekit (client) 42.6 kB +0.04% +14 B 🔺
@sentry/node-core 52.18 kB +0.05% +26 B 🔺
@sentry/node 166.19 kB +0.02% +27 B 🔺
@sentry/node - without tracing 93.96 kB +0.04% +33 B 🔺
@sentry/aws-serverless 109.48 kB +0.03% +30 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

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.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,122 - 9,138 -0%
GET With Sentry 1,673 18% 1,775 -6%
GET With Sentry (error only) 6,114 67% 6,108 +0%
POST Baseline 1,187 - 1,196 -1%
POST With Sentry 580 49% 605 -4%
POST With Sentry (error only) 1,059 89% 1,054 +0%
MYSQL Baseline 3,297 - 3,343 -1%
MYSQL With Sentry 407 12% 512 -21%
MYSQL With Sentry (error only) 2,683 81% 2,707 -1%

View base workflow run

@logaretm logaretm merged commit 170b6f8 into develop Jan 30, 2026
421 of 423 checks passed
@logaretm logaretm deleted the awad/js-1606-event-processor-errors-cause-silent-event-loss-via-infinite branch January 30, 2026 22:00
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.

Event processor errors cause silent event loss via infinite recursion

3 participants