Skip to content

feat(core): Record callback_error client reports for throwing user callbacks - #23903

Open
msonnb wants to merge 1 commit into
developfrom
ms/callback-error-drop-reason
Open

feat(core): Record callback_error client reports for throwing user callbacks#23903
msonnb wants to merge 1 commit into
developfrom
ms/callback-error-drop-reason

Conversation

@msonnb

@msonnb msonnb commented Sep 2, 2026

Copy link
Copy Markdown
Member

Drops caused by a throwing user callback were reported with the same client report reason as a legitimate filter. They now use a new callback_error reason so the two are distinguishable.

Part of #23755

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.73 kB +0.09% +24 B 🔺
@sentry/browser - with treeshaking flags 27.04 kB +0.09% +24 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.94 kB +0.11% +28 B 🔺
@sentry/browser (incl. Tracing) 49.16 kB +0.12% +55 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 49.17 kB +0.15% +69 B 🔺
@sentry/browser (incl. Tracing, Profiling) 52.09 kB +0.15% +78 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.65 kB +0.09% +73 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.93 kB +0.07% +50 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 93.33 kB +0.08% +66 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 106.3 kB +0.09% +85 B 🔺
@sentry/browser (incl. Feedback) 46.23 kB +0.08% +33 B 🔺
@sentry/browser (incl. sendFeedback) 33.79 kB +0.05% +16 B 🔺
@sentry/browser (incl. FeedbackAsync) 38.9 kB +0.07% +25 B 🔺
@sentry/browser (incl. Metrics) 29.75 kB +0.22% +65 B 🔺
@sentry/browser (incl. Logs) 30.02 kB +0.19% +55 B 🔺
@sentry/browser (incl. Metrics & Logs) 30.68 kB +0.21% +62 B 🔺
@sentry/react 30.51 kB +0.12% +35 B 🔺
@sentry/react (incl. Tracing) 51.39 kB +0.17% +86 B 🔺
@sentry/vue 36.01 kB +0.2% +69 B 🔺
@sentry/vue (incl. Tracing) 51.44 kB +0.15% +77 B 🔺
@sentry/svelte 28.76 kB +0.09% +23 B 🔺
CDN Bundle 30.48 kB +0.1% +28 B 🔺
CDN Bundle (incl. Tracing) 49.73 kB +0.19% +91 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.76 kB +0.22% +70 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 51.67 kB +0.23% +114 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.34 kB +0.09% +60 B 🔺
CDN Bundle (incl. Tracing, Replay) 87.2 kB +0.09% +72 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.09 kB +0.11% +95 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 93.13 kB +0.08% +69 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.11 kB +0.12% +106 B 🔺
CDN Bundle - uncompressed 90.29 kB +0.12% +101 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 148.18 kB +0.22% +312 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.82 kB +0.26% +243 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.1 kB +0.3% +454 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.99 kB +0.11% +243 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.68 kB +0.12% +312 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.58 kB +0.17% +454 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.38 kB +0.12% +312 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.28 kB +0.16% +454 B 🔺
@sentry/nextjs (client) 53.99 kB +0.15% +78 B 🔺
@sentry/sveltekit (client) 49.62 kB +0.18% +89 B 🔺
@sentry/core/server 41.04 kB +0.2% +80 B 🔺
@sentry/core/browser 13.58 kB +0.37% +50 B 🔺
@sentry/node 124.75 kB +0.1% +116 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB - -
@sentry/node - without tracing 88.57 kB +0.12% +99 B 🔺
@sentry/node - without channel injection 104.05 kB +0.12% +121 B 🔺
@sentry/aws-serverless 96.98 kB +0.15% +137 B 🔺
@sentry/cloudflare (withSentry) - minified 201.89 kB +0.17% +329 B 🔺
@sentry/cloudflare (withSentry) 501.81 kB +0.09% +444 B 🔺

View base workflow run

Base automatically changed from ms/safe-callback-user-callbacks to develop September 3, 2026 09:16
@msonnb
msonnb force-pushed the ms/callback-error-drop-reason branch from d9e33fd to dd74588 Compare September 3, 2026 09:16
…callbacks

Events, logs, metrics and root spans dropped because a user callback threw
were reported with the same outcome as a legitimate filter (`before_send`,
`event_processor`, `sample_rate`). A dedicated `callback_error` reason makes
them distinguishable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@msonnb
msonnb force-pushed the ms/callback-error-drop-reason branch from dd74588 to 8f068cc Compare September 3, 2026 09:42
@msonnb

msonnb commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8f068cc. Configure here.

@msonnb
msonnb marked this pull request as ready for review September 3, 2026 12:11
@msonnb
msonnb requested a review from a team as a code owner September 3, 2026 12:11
@msonnb
msonnb requested review from Lms24, isaacs and mydea and removed request for a team September 3, 2026 12:11
samplingContext: SamplingContext,
sampleRand: number,
): [sampled: boolean, sampleRate?: number, localSampleRateWasApplied?: boolean] {
): SamplingDecision {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: this is API breaking, since sampleSpan is exported. I agree that the object is easier to read though . IIRC, we used the named tuple here for bundle size minimization but this is less readable than the refactor.

Breaking here isn't a big deal though, so we can also do it if the tuple no longer works. But if we do, let's add a note in the migration guide.

() => processor({ ...event }, hint),
() => null,
() => {
throw CALLBACK_ERROR;

@Lms24 Lms24 Sep 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: throwing here and in client.ts made me a bit suspicious because we have to be really careful to also catch our throws. Looks like there's a case in replay where we also call prepareEvent which doesn't try/catch the call. I think this only concerns event processor throws though. This leads to us trying to re-send the replay because we assume a network error. Ultimately, we stop recording.

I think we have two options how to avoid this:

  1. we try/catch in Replay so that this doesn't happen
  2. we don't throw at all. Instead, we could directly record an dropped event in notifyEventProcessors and distinguish there.

Tbqh: I haven't thought this through end-to-end, so maybe 1 is easier. I don't see us reusing prepareEvent much in the foreseeable future. But happy to let you make the call (also feel free to come up with something else).

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.

2 participants