Skip to content

Callback error isolation: align beforeBreadcrumb / tracesSampler fallbacks with the SDK spec #6668

Description

@antonis

Tracking deviations from the Callback Error Isolation spec (sentry-docs PR #19189), surfaced by the Linear initiative Wrap all SDK user callbacks in a try/catch.

RN already wraps user callbacks (safeFactory / safeTracesSampler in packages/core/src/js/utils/safe.ts, applied in sdk.tsx) and logs via debug.error, does not re-throw, and does not self-capture — so the error-log / no-rethrow / no-capture requirements are met. Two recovery values deviate from the spec's fallback matrix:

1. tracesSampler throw → returns 0 (forces 0% sampling)

safe.ts:50 returns 0 on failure. The spec says fall back to traces_sample_rate and MUST NOT substitute 0.0/1.0. Silently dropping all transactions on a sampler bug is exactly the substitution the spec forbids.

→ Fall back to the configured tracesSampleRate instead.

2. beforeBreadcrumb throw → keeps the original breadcrumb

safeFactory returns args[0] on failure (safe.ts:29), so a throwing beforeBreadcrumb keeps the unmodified breadcrumb. The spec says drop the breadcrumb (client report None).

→ Return null on failure for the breadcrumb case.

Not in scope / not RN-specific

  • beforeSend, beforeSendTransaction, beforeSendSpan, beforeSendLog, and event processors are handled by the @sentry/core pipeline (_processEvent), not by RN — including the new callback_error client-report reason. Any gap there belongs to @sentry/javascript.
  • profilesSampler / error_sampler don't exist in RN (only profilesSampleRate), so those rows don't apply.
  • initialScope, integrations, and withScope get extra RN-side isolation not in the core matrix — reasonable, left as-is.

Caveat

The spec is still candidate and in active review (PR #19189 has open proposals to narrow isolation to "recoverable" errors and to drop before_send_metric). Neither affects the two items above.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions