Commit fcaeb0f
authored
perf: switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) (#474)
## Summary
Switch from `@sentry/bun` to `@sentry/node-core/light` to eliminate the
OpenTelemetry dependency tree that a CLI tool never uses. Additionally,
patch `@sentry/core` barrel to remove unused modules (AI tracing, MCP
server, Supabase, feature flags).
## Changes
### Phase 1: SDK upgrade
- Upgrade Sentry SDK `10.39.0` → `10.44.0`
### Phase 2: Import migration (~150ms savings)
- Replace `@sentry/bun` + `@sentry/node` dependencies with
`@sentry/node-core`
- Replace all `import * as Sentry from "@sentry/bun"` →
`"@sentry/node-core/light"` (15 source files, 4 test files)
- Change `BunClient` → `LightNodeClient` in telemetry.ts
- Export `Span` type from `@sentry/core` (canonical source)
- Remove esbuild `@sentry/bun` → `@sentry/node` alias in bundle.ts (no
longer needed)
### Phase 3: Barrel patching (~14ms savings)
- Patch `@sentry/core` barrel to remove 32 export lines pulling in ~59
unused transitive modules (AI tracing integrations, MCP server,
Supabase, feature flags, etc.)
- Patch `@sentry/node-core/light` barrel to remove 11 matching
re-exports
### Phase 4: Upstream issue drafts
- Added `.github/upstream-issues/` with drafts for:
- `@sentry/core/light` sub-path export request
- `@sentry/bun/light` entry point request
## What we lose (nothing meaningful)
| Feature | Why irrelevant |
|---------|---------------|
| 29 OpenTelemetry auto-instrumentations | CLI is not a web server |
| `bunServerIntegration` | CLI does not call `Bun.serve()` |
| `BunClient` class | Deprecated since v9; replaced by `LightNodeClient`
|
| Bun-native fetch transport | `makeNodeTransport` works fine in Bun |
| OTEL context propagation | Light mode uses `AsyncLocalStorage` — same
behavior |
| SDK envelope metadata `"bun"` | Changes to `"node-light"` — cosmetic
only. `cli.runtime` tag still distinguishes Bun vs Node |
## API compatibility verified
Every API the CLI uses (`captureException`, `startSpan`, `setTag`,
`metrics`, `logger`, `createConsolaReporter`, `getTraceData`,
`isEnabled`, `flush`, `endSession`, etc.) is available in
`@sentry/node-core/light`.
## Risk
Light mode is labeled experimental, but we pin SDK versions exactly
(`10.44.0`, not `^10.44.0`), so we control when SDK updates happen.
## Verification
- ✅ `bun run typecheck` — clean
- ✅ `bun run test:unit` — 3883/3885 pass (2 pre-existing flaky failures
in upgrade tests)
- ✅ `bun run test:isolated` — 126/126 pass
- ✅ `bun run check:skill` — up to date
- ✅ `bun run check:errors` — no anti-patterns
- ✅ Patched SDK exports all needed symbols, removed symbols are
`undefined`
- 📊 SDK import time: ~114ms (down from ~285ms)
Closes #4721 parent 12b2c8b commit fcaeb0f
File tree
26 files changed
+457
-138
lines changed- .github/upstream-issues
- patches
- script
- src
- commands
- cli
- log
- lib
- api
- dsn
- formatters
- init
- test
- isolated/dsn
- lib
26 files changed
+457
-138
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments