Skip to content

perf: switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings)#474

Merged
BYK merged 2 commits intomainfrom
perf/sentry-sdk-light
Mar 19, 2026
Merged

perf: switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings)#474
BYK merged 2 commits intomainfrom
perf/sentry-sdk-light

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 19, 2026

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.010.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 BunClientLightNodeClient 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 #472

…tup savings)

Replace @sentry/bun (which pulls in the full OpenTelemetry stack and 29+
auto-instrumentation modules) with @sentry/node-core/light for ~150ms
import time savings.

Additionally, patch @sentry/core barrel to remove 32 unused export lines
(AI tracing, MCP server, Supabase, feature flags, etc.) for ~14ms more.

Changes:
- Upgrade Sentry SDK 10.39.0 → 10.44.0
- Replace all @sentry/bun imports → @sentry/node-core/light (15 src 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
- Add patches for @sentry/core and @sentry/node-core barrels
- Update test imports and mock targets (4 test files)
- Add upstream issue drafts for @sentry/core/light and @sentry/bun/light

Closes #472
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482

Bug Fixes 🐛

  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475

Internal Changes 🔧

  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1034 uncovered lines.
✅ Project coverage is 95.71%. Comparing base (base) to head (head).

Files with missing lines (7)
File Patch % Lines
human.ts 96.35% ⚠️ 46 Missing
telemetry.ts 91.94% ⚠️ 37 Missing
delta-upgrade.ts 95.38% ⚠️ 32 Missing
sentry-client.ts 93.42% ⚠️ 15 Missing
interactive-login.ts 92.16% ⚠️ 8 Missing
code-scanner.ts 98.20% ⚠️ 6 Missing
infrastructure.ts 99.50% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.71%    95.71%        —%
==========================================
  Files          177       177         —
  Lines        24091     24100        +9
  Branches         0         0         —
==========================================
+ Hits         23057     23066        +9
- Misses        1034      1034         —
- Partials         0         0         —

Generated by Codecov Action

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

- Fix BunClient → LightNodeClient type in telemetry-session test
- Remove dead empty alias object from esbuild config
- Override LightNodeClient runtime metadata to report bun when running
  as a compiled Bun binary (the client hardcodes 'node')
@BYK BYK merged commit fcaeb0f into main Mar 19, 2026
22 checks passed
@BYK BYK deleted the perf/sentry-sdk-light branch March 19, 2026 20:17
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.

perf: switch from @sentry/bun to @sentry/node-core/light (~150ms startup savings)

1 participant