diff --git a/docs/guides/examples/sentry-error-tracking.mdx b/docs/guides/examples/sentry-error-tracking.mdx index 422a4f9dca..3af32bdbd0 100644 --- a/docs/guides/examples/sentry-error-tracking.mdx +++ b/docs/guides/examples/sentry-error-tracking.mdx @@ -62,6 +62,39 @@ export default defineConfig({ deploying). You can use pre-built extensions or create your own. +### Bun runtime + +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: + +```ts trigger.config.ts +import { defineConfig } from "@trigger.dev/sdk"; +import { esbuildPlugin } from "@trigger.dev/build/extensions"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; + +export default defineConfig({ + project: "", + runtime: "bun", + build: { + extensions: [ + { + name: "sentry-external-dev", + externalsForTarget: (target) => (target === "dev" ? ["@sentry/node"] : []), + }, + esbuildPlugin( + sentryEsbuildPlugin({ + org: "", + project: "", + authToken: process.env.SENTRY_AUTH_TOKEN, + }), + { placement: "last", target: "deploy" } + ), + ], + }, +}); +``` + +This lets Bun resolve `@sentry/node` directly from `node_modules` during dev, while still bundling it normally for deployment. + ### Runtime initialization Create a `trigger/init.ts` file to initialize Sentry and register the global `onFailure` hook. This file is automatically loaded when your tasks execute.