Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/cli-v3/src/entryPoints/dev-index-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ import {
} from "@trigger.dev/core/v3/workers";
import { sendMessageInCatalog, ZodSchemaParsedError } from "@trigger.dev/core/v3/zodMessageHandler";
import { readFile } from "node:fs/promises";
import sourceMapSupport from "source-map-support";
import { registerResources } from "../indexing/registerResources.js";
import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js";
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { detectRuntimeVersion } from "@trigger.dev/core/v3/build";
import { schemaToJsonSchema } from "@trigger.dev/schema-to-json";

sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
installSourceMapSupport();

process.on("uncaughtException", function (error, origin) {
if (error instanceof Error) {
Expand Down
8 changes: 2 additions & 6 deletions packages/cli-v3/src/entryPoints/dev-run-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ import {
import { ZodIpcConnection } from "@trigger.dev/core/v3/zodIpc";
import { readFile } from "node:fs/promises";
import { setInterval, setTimeout } from "node:timers/promises";
import sourceMapSupport from "source-map-support";
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";

sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
installSourceMapSupport();

process.on("uncaughtException", function (error, origin) {
logError("Uncaught exception", { error, origin });
Expand Down
8 changes: 2 additions & 6 deletions packages/cli-v3/src/entryPoints/managed-index-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ import {
} from "@trigger.dev/core/v3/workers";
import { sendMessageInCatalog, ZodSchemaParsedError } from "@trigger.dev/core/v3/zodMessageHandler";
import { readFile } from "node:fs/promises";
import sourceMapSupport from "source-map-support";
import { registerResources } from "../indexing/registerResources.js";
import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js";
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { detectRuntimeVersion } from "@trigger.dev/core/v3/build";
import { schemaToJsonSchema } from "@trigger.dev/schema-to-json";

sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
installSourceMapSupport();

process.on("uncaughtException", function (error, origin) {
if (error instanceof Error) {
Expand Down
8 changes: 2 additions & 6 deletions packages/cli-v3/src/entryPoints/managed-run-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ import {
import { ZodIpcConnection } from "@trigger.dev/core/v3/zodIpc";
import { readFile } from "node:fs/promises";
import { setInterval, setTimeout } from "node:timers/promises";
import sourceMapSupport from "source-map-support";
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { installSourceMapSupport } from "../utilities/installSourceMapSupport.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";

sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
installSourceMapSupport();

process.on("uncaughtException", function (error, origin) {
console.error("Uncaught exception", { error, origin });
Expand Down
32 changes: 32 additions & 0 deletions packages/cli-v3/src/utilities/installSourceMapSupport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sourceMapSupport from "source-map-support";

/**
* Installs source-map-support with a workaround for Bun's source map handling.
*
* Bun's runtime can produce source maps with column values of -1, which causes
* source-map@0.6.1 (used by source-map-support) to throw:
* "Column must be greater than or equal to 0, got -1"
*
* This wraps the prepareStackTrace hook so that if source map processing fails,
* it falls back to default stack trace formatting instead of crashing.
*
* See: https://github.com/oven-sh/bun/issues/8087
*/
export function installSourceMapSupport() {
sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});

const _prepareStackTrace = (Error as any).prepareStackTrace;
if (_prepareStackTrace) {
(Error as any).prepareStackTrace = (error: Error, stackTraces: NodeJS.CallSite[]) => {
try {
return _prepareStackTrace(error, stackTraces);
} catch {
return `${error}\n` + stackTraces.map((s) => ` at ${s}`).join("\n");
}
};
}
}