File tree Expand file tree Collapse file tree 5 files changed +40
-24
lines changed
Expand file tree Collapse file tree 5 files changed +40
-24
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,14 @@ import {
1313} from "@trigger.dev/core/v3/workers" ;
1414import { sendMessageInCatalog , ZodSchemaParsedError } from "@trigger.dev/core/v3/zodMessageHandler" ;
1515import { readFile } from "node:fs/promises" ;
16- import sourceMapSupport from "source-map-support" ;
1716import { registerResources } from "../indexing/registerResources.js" ;
17+ import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js" ;
1818import { env } from "std-env" ;
1919import { normalizeImportPath } from "../utilities/normalizeImportPath.js" ;
2020import { detectRuntimeVersion } from "@trigger.dev/core/v3/build" ;
2121import { schemaToJsonSchema } from "@trigger.dev/schema-to-json" ;
2222
23- sourceMapSupport . install ( {
24- handleUncaughtExceptions : false ,
25- environment : "node" ,
26- hookRequire : false ,
27- } ) ;
23+ installSourceMapSupport ( ) ;
2824
2925process . on ( "uncaughtException" , function ( error , origin ) {
3026 if ( error instanceof Error ) {
Original file line number Diff line number Diff line change @@ -63,17 +63,13 @@ import {
6363import { ZodIpcConnection } from "@trigger.dev/core/v3/zodIpc" ;
6464import { readFile } from "node:fs/promises" ;
6565import { setInterval , setTimeout } from "node:timers/promises" ;
66- import sourceMapSupport from "source-map-support" ;
6766import { env } from "std-env" ;
6867import { normalizeImportPath } from "../utilities/normalizeImportPath.js" ;
68+ import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js" ;
6969import { VERSION } from "../version.js" ;
7070import { promiseWithResolvers } from "@trigger.dev/core/utils" ;
7171
72- sourceMapSupport . install ( {
73- handleUncaughtExceptions : false ,
74- environment : "node" ,
75- hookRequire : false ,
76- } ) ;
72+ installSourceMapSupport ( ) ;
7773
7874process . on ( "uncaughtException" , function ( error , origin ) {
7975 logError ( "Uncaught exception" , { error, origin } ) ;
Original file line number Diff line number Diff line change @@ -13,18 +13,14 @@ import {
1313} from "@trigger.dev/core/v3/workers" ;
1414import { sendMessageInCatalog , ZodSchemaParsedError } from "@trigger.dev/core/v3/zodMessageHandler" ;
1515import { readFile } from "node:fs/promises" ;
16- import sourceMapSupport from "source-map-support" ;
1716import { registerResources } from "../indexing/registerResources.js" ;
17+ import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js" ;
1818import { env } from "std-env" ;
1919import { normalizeImportPath } from "../utilities/normalizeImportPath.js" ;
2020import { detectRuntimeVersion } from "@trigger.dev/core/v3/build" ;
2121import { schemaToJsonSchema } from "@trigger.dev/schema-to-json" ;
2222
23- sourceMapSupport . install ( {
24- handleUncaughtExceptions : false ,
25- environment : "node" ,
26- hookRequire : false ,
27- } ) ;
23+ installSourceMapSupport ( ) ;
2824
2925process . on ( "uncaughtException" , function ( error , origin ) {
3026 if ( error instanceof Error ) {
Original file line number Diff line number Diff line change @@ -63,17 +63,13 @@ import {
6363import { ZodIpcConnection } from "@trigger.dev/core/v3/zodIpc" ;
6464import { readFile } from "node:fs/promises" ;
6565import { setInterval , setTimeout } from "node:timers/promises" ;
66- import sourceMapSupport from "source-map-support" ;
6766import { env } from "std-env" ;
6867import { normalizeImportPath } from "../utilities/normalizeImportPath.js" ;
68+ import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js" ;
6969import { VERSION } from "../version.js" ;
7070import { promiseWithResolvers } from "@trigger.dev/core/utils" ;
7171
72- sourceMapSupport . install ( {
73- handleUncaughtExceptions : false ,
74- environment : "node" ,
75- hookRequire : false ,
76- } ) ;
72+ installSourceMapSupport ( ) ;
7773
7874process . on ( "uncaughtException" , function ( error , origin ) {
7975 console . error ( "Uncaught exception" , { error, origin } ) ;
Original file line number Diff line number Diff line change 1+ import sourceMapSupport from "source-map-support" ;
2+
3+ /**
4+ * Installs source-map-support with a workaround for Bun's source map handling.
5+ *
6+ * Bun's runtime can produce source maps with column values of -1, which causes
7+ * source-map@0.6.1 (used by source-map-support) to throw:
8+ * "Column must be greater than or equal to 0, got -1"
9+ *
10+ * This wraps the prepareStackTrace hook so that if source map processing fails,
11+ * it falls back to default stack trace formatting instead of crashing.
12+ *
13+ * See: https://github.com/oven-sh/bun/issues/8087
14+ */
15+ export function installSourceMapSupport ( ) {
16+ sourceMapSupport . install ( {
17+ handleUncaughtExceptions : false ,
18+ environment : "node" ,
19+ hookRequire : false ,
20+ } ) ;
21+
22+ const _prepareStackTrace = ( Error as any ) . prepareStackTrace ;
23+ if ( _prepareStackTrace ) {
24+ ( Error as any ) . prepareStackTrace = ( error : Error , stackTraces : NodeJS . CallSite [ ] ) => {
25+ try {
26+ return _prepareStackTrace ( error , stackTraces ) ;
27+ } catch {
28+ return `${ error } \n` + stackTraces . map ( ( s ) => ` at ${ s } ` ) . join ( "\n" ) ;
29+ }
30+ } ;
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments