Bun
This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.
@bugsee/bun is the SDK for Bun. It runs the same pipeline as the Node.js SDK (crash and error capture, console and network capture, on-disk capture with crash recovery, hang detection and profiling) and adds automatic instrumentation of Bun.serve requests. It only changes how the runtime is identified in reports: bun and its version.
Requirements
- Bun 1.1.13 or newer. The SDK is tested on Bun 1.3.
- An app token. Create a JavaScript application in Bugsee and choose Bun as its target; see Create your app.
Install
- npm
- pnpm
- yarn
- bun
npm install @bugsee/bun
pnpm add @bugsee/bun
yarn add @bugsee/bun
bun add @bugsee/bun
Install @bugsee/bun in a Bun project. It does not include the umbrella's extensions (performance monitoring and OpenTelemetry). If you also use a backend framework adapter, install @bugsee/bun next to it and import launch from @bugsee/bun; see Running on Bun.
Launch
Call launch() at the top of your entry file. It returns the client directly, not a Promise.
import { launch } from '@bugsee/bun';
const bugsee = launch('<your_app_token>', { appVersion: '1.4.2' });
Bun.serve({
port: 3000,
fetch() {
return new Response('ok');
},
});
Incoming Bun.serve requests are instrumented automatically. Each request gets its own request context. Pass instrumentIncomingRequests: false to opt out. Frameworks that run on node:http are covered by the node:http instrumentation; see Backend.
What is exported
@bugsee/bun re-exports everything from the Node build (@bugsee/node) and adds the following:
| Export | Description |
|---|---|
launch(appToken, options?) | Starts the SDK and returns the client synchronously. |
relaunch(options?) | Restarts the SDK, optionally with new options. |
launchCore | The composition root behind launch. Returns more than the client. |
createBunServeInterceptor | The Bun.serve instrumentation that launch installs. |
bunSystemProbe, createBunSystemProbe | The probe that identifies the runtime as bun. |
Options
launch(appToken, options) takes the same options as on Node.js. See Node.js options and Configuration. Common ones:
| Option | Type | Default | Description |
|---|---|---|---|
appVersion, appBuild, appId | string | resolved | Identify your release in reports. |
captureLogs, captureNetwork, captureNetworkBodies | boolean | true | Capture streams. |
maxRecordingTime | number | 60 | Rolling recording window, in seconds. |
dataDir | string | <os tmpdir>/bugsee | Directory for the on-disk buffer. |
detectHangs | boolean | true | Event-loop hang detection. |
profiling | boolean | false | Rolling CPU profile attached to reports. |
instrumentIncomingRequests | boolean | true | Automatic Bun.serve request instrumentation. |
Differences from Node.js
captureLocalVariablesis always off. Bun refuses the debugger API that the feature needs unless an inspector is open, so the SDK forces the option off even if you set it.- Some system traces are omitted rather than reported as zero. On Bun, the event-loop utilization and garbage-collection data are not reliable, and V8 heap figures do not apply, so the SDK leaves those traces out of Bun reports.
- Both
Bun.serveandnode:httpare instrumented. The Nodenode:httpinstrumentation also runs under Bun wheninstrumentIncomingRequestsis on.
Source maps
If you bundle with bun build, inject debug IDs and upload the maps yourself. See Manual source map upload.
Verify
- Launch the SDK with a real token.
- Report a test error:
const bugsee = launch('<your_app_token>');
bugsee.logException(new Error('Bugsee test error'));
await bugsee.flush();
- Open the Bugsee dashboard. The report appears within a minute, with
bunand its version in the environment.
Related pages
- Node.js — the options and behavior Bun shares
- Backend — request context and framework adapters
- Configuration — all launch options
- Symbolication — source maps and debug IDs