Skip to content

Commit

Permalink
[v7] Bun Global Unhandled Handlers (#11959)
Browse files Browse the repository at this point in the history
Add support for global onUnhandled Error/Promise for Bun.

```javascript
import * as Sentry from "@sentry/bun";

Sentry.init({
    dsn: "DSN",
});

console.log("Hello via Bun!");

throw new Error('Unhandled Bun Sentry Error!');
```

<img width="1063" alt="image"
src="https://github.com/getsentry/sentry-javascript/assets/363802/fd90969f-82a4-4300-a67e-1ebb5cf540fa">

ref: oven-sh/bun#5091
  • Loading branch information
HazAT authored May 10, 2024
1 parent 02bc198 commit 75e5501
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
modulesIntegration,
nativeNodeFetchintegration,
nodeContextIntegration,
onUncaughtExceptionIntegration,
onUnhandledRejectionIntegration,
} from '@sentry/node';
import type { Integration, Options } from '@sentry/types';

Expand All @@ -32,9 +34,9 @@ export const defaultIntegrations = [
consoleIntegration(),
httpIntegration(),
nativeNodeFetchintegration(),
// Global Handlers # TODO (waiting for https://github.com/oven-sh/bun/issues/5091)
// new NodeIntegrations.OnUncaughtException(),
// new NodeIntegrations.OnUnhandledRejection(),
// Global Handlers
onUncaughtExceptionIntegration(),
onUnhandledRejectionIntegration(),
// Event Info
contextLinesIntegration(),
// new NodeIntegrations.LocalVariables(), # does't work with Bun
Expand Down

0 comments on commit 75e5501

Please sign in to comment.