Skip to content

fix(effect): Stop bundling all of Effect with the error reporter - #26730

Draft
JPeer264 wants to merge 2 commits into
jp/effect-size-limitfrom
jp/effect-error-reporter-bundle-size
Draft

JPeer264 wants to merge 2 commits into
jp/effect-size-limitfrom
jp/effect-error-reporter-bundle-size

Conversation

@JPeer264

@JPeer264 JPeer264 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

This stops effectLayer from pulling all of Effect into the bundle. The error reporter now uses the string keys of Effect's ErrorReporter API and a Context.Reference with the key of CurrentErrorReporters, instead of reading ErrorReporter from the effect main entry. One build still works with Effect v3 and v4.

Why

The Reflect.get lookup on the effect namespace made bundlers keep every export of Effect, about 250 KB gzipped.

Known issues

  • The reporter depends on the key effect/ErrorReporter/CurrentErrorReporters, which Effect does not export as a type. The unit tests fail when an Effect update changes it.

The error reporter read `ErrorReporter` off the `effect` main entry with
`Reflect.get`, which made bundlers keep every export of Effect (about
250 KB gzipped). It now uses the string keys of Effect's ErrorReporter API
and a `Context.Reference` with the key of `CurrentErrorReporters`, so the
same build still works with Effect v3 and v4 and tree-shakes.

`contextExports` moves into `compat.ts` together with `isEffectV4`, because
Rolldown folds a single-use local alias back into `Context.Reference`, which
webpack rejects on Effect v3 before 3.11.

One reporter instance now serves every Sentry layer, so a failure that is
not an object is captured once when the layer is provided twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: e07f417 (PR test merge using jp/effect-size-limit at 1b07799)

Against: ef89ae2 (jp/effect-size-limit) · base run #67360

⚠️ Baseline mismatch: 1 jp/effect-size-limit commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once jp/effect-size-limit's baseline build for 1b07799 finishes.

Path Size % Change Change
@sentry/browser 30.23 kB - -
@sentry/browser - with treeshaking flags 28.43 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.33 kB - -
@sentry/browser (incl. Tracing) 52.81 kB - -
@sentry/browser (incl. Tracing Core) 40.33 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.81 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.69 kB - -
@sentry/browser (incl. Tracing, Replay) 92.88 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.7 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.22 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.8 kB - -
@sentry/browser (incl. Feedback) 48.17 kB - -
@sentry/browser (incl. sendFeedback) 30.81 kB - -
@sentry/browser (incl. FeedbackAsync) 35.84 kB - -
@sentry/browser (incl. Metrics) 31.55 kB - -
@sentry/browser (incl. Logs) 31.83 kB - -
@sentry/browser (incl. Metrics & Logs) 32.49 kB - -
@sentry/react 32.24 kB - -
@sentry/react (incl. Tracing) 55.45 kB - -
@sentry/vue 38.45 kB - -
@sentry/vue (incl. Tracing) 55.75 kB - -
@sentry/svelte 30.24 kB - -
@sentry/remix (Remix 3 client bundle) 58.46 kB - -
CDN Bundle 32.16 kB - -
CDN Bundle (incl. Tracing) 53.19 kB - -
CDN Bundle (incl. Logs, Metrics) 34.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.02 kB - -
CDN Bundle (incl. Tracing, Replay) 91.1 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.51 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.07 kB - -
CDN Bundle - uncompressed 93.91 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.26 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 164.88 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.48 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.53 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.08 kB - -
@sentry/nextjs (client) 59.15 kB - -
@sentry/sveltekit (client) 54.06 kB - -
@sentry/core/server 45.28 kB - -
@sentry/core/browser 14.41 kB - -
@sentry/node 154.01 kB -0.01% -7 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.33 kB - -
@sentry/node - without tracing 88.81 kB -0.01% -1 B 🔽
@sentry/node - without channel injection 142.98 kB -0.01% -6 B 🔽
@sentry/aws-serverless 99.41 kB -0.01% -3 B 🔽
@sentry/cloudflare (withSentry) - minified 208.5 kB - -
@sentry/cloudflare (withSentry) 483.88 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 1.02 MB - -
@sentry/nextjs/cloudflare (withSentry) - minified 233.74 kB - -
@sentry/effect (client) 41.89 kB added added
@sentry/effect (client, incl. Tracing) 49.08 kB added added
@sentry/effect (client, incl. Tracing, Logs, Metrics) 58.96 kB added added

View base workflow run

@JPeer264
JPeer264 added this pull request to stack #26733 November 22, 2026 16:06

This branch has not been deployed

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

1 participant