Skip to content

Commit 2c1a2d1

Browse files
committed
docs: add Bun runtime setup for Sentry error tracking
1 parent dbbe9f7 commit 2c1a2d1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/guides/examples/sentry-error-tracking.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,39 @@ export default defineConfig({
6262
deploying). You can use pre-built extensions or create your own.
6363
</Note>
6464

65+
### Bun runtime
66+
67+
If you are using the Bun runtime, esbuild's bundling of `@sentry/node`'s CJS entry can cause a runtime error in the local dev environment. Add the following extension to mark `@sentry/node` as external in dev only:
68+
69+
```ts trigger.config.ts
70+
import { defineConfig } from "@trigger.dev/sdk";
71+
import { esbuildPlugin } from "@trigger.dev/build/extensions";
72+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
73+
74+
export default defineConfig({
75+
project: "<project ref>",
76+
runtime: "bun",
77+
build: {
78+
extensions: [
79+
{
80+
name: "sentry-external-dev",
81+
externalsForTarget: (target) => (target === "dev" ? ["@sentry/node"] : []),
82+
},
83+
esbuildPlugin(
84+
sentryEsbuildPlugin({
85+
org: "<your-sentry-org>",
86+
project: "<your-sentry-project>",
87+
authToken: process.env.SENTRY_AUTH_TOKEN,
88+
}),
89+
{ placement: "last", target: "deploy" }
90+
),
91+
],
92+
},
93+
});
94+
```
95+
96+
This lets Bun resolve `@sentry/node` directly from `node_modules` during dev, while still bundling it normally for deployment.
97+
6598
### Runtime initialization
6699

67100
Create a `trigger/init.ts` file to initialize Sentry and register the global `onFailure` hook. This file is automatically loaded when your tasks execute.

0 commit comments

Comments
 (0)