feat(bun): Add @sentry/bun/light entry point without OpenTelemetry#20622
feat(bun): Add @sentry/bun/light entry point without OpenTelemetry#20622MathurAditya724 wants to merge 3 commits intodevelopfrom
Conversation
Adds a new `@sentry/bun/light` entry point that mirrors what `@sentry/node-core/light` does for Node.js: it uses AsyncLocalStorage for context propagation instead of OpenTelemetry, eliminating the ~150ms import overhead and ~24MB of OTel packages for CLI tools and other non-server Bun applications. The new entry point provides: - `BunLightClient` extending `LightNodeClient` with Bun-specific runtime metadata (name: 'bun', version: Bun.version) - `makeFetchTransport` as the default transport (uses global fetch()) - SDK metadata tagged as 'sentry.javascript.bun' - All common Sentry APIs (captureException, startSpan, setTag, etc.) - No bunServerIntegration or OTel auto-instrumentation in defaults Fixes #19886 Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
- Convert rollup externals to a function matching dependency subpaths so @sentry/node-core/light stays external (fixes import-in-the-middle resolution error) - Set moduleResolution to Node16 in tsconfig so TypeScript resolves @sentry/node-core/light subpath exports - Use type assertion in LightNodeClient for platform/runtime overrides since NodeClientOptions doesn't include ServerRuntimeClientOptions fields - Remove BunLightClient wrapper in favor of passing platform/runtime through options directly to LightNodeClient
|
fix-ci: starting attempt 1 fix-ci: result — pushed Root causes:
Fixes:
|
size-limit report 📦
|
|
fix-ci: starting attempt CI failure: |
|
fix-ci: result Fixed The optional |
Adds a
@sentry/bun/lightentry point that eliminates the ~150ms import overhead and ~24MB of OTel packages for CLI tools and non-server Bun applications. UsesAsyncLocalStoragefor context propagation instead of OpenTelemetry, and sets Bun-specific runtime metadata (name: 'bun',version: Bun.version).What this changes
packages/bun/src/light/directory withBunLightClient,init,getDefaultIntegrations, andinitWithoutDefaultIntegrationsBunLightClientextendsLightNodeClientand overrides runtime/platform metadata to reflect BunmakeFetchTransportis the default transport (uses globalfetch())sentry.javascript.bunbunServerIntegrationor OTel auto-instrumentation in defaultspackage.jsonupdated with./lightexport map and@sentry/node-coredirect dependencyrollup.npm.config.mjsupdated to includesrc/light/index.tsas an entry pointWhat's complete
BunLightClientwith correct Bun runtime metadatainit/initWithoutDefaultIntegrationsfunctions@sentry/coreand@sentry/node-core/lightWhat's incomplete or uncertain
BunLightClientconstructor mutatesgetOptions()aftersuper()to override the Node.js runtime set byLightNodeClient. This is a workaround forLightNodeClienthardcodingruntime: { name: 'node' }. A cleaner approach would be to haveLightNodeClientaccept runtime overrides, but that's a separate change.debugoption handling omits theDEBUG_BUILDguard (the bun package has nodebug-build.ts). This meansdebug.enable()is always called whendebug: true, even in non-debug bundles.processSessionIntegrationin defaults (it's not exported from@sentry/node-core/light).typesVersionsdoes not include the./lightsub-path (consistent with@sentry/node-corewhich also omits it).Followups
processSessionIntegrationto@sentry/node-core/lightexportsdebug-build.tsto the bun package for proper debug bundle handlingTesting
Ran
bun testinpackages/bun/— 40 pass, 0 fail.Closes #19886