Skip to content
Closed
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
28 changes: 22 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,29 @@ 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 { 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,
});
let sourceMapSupportInstalled = false;

async function installSourceMapSupport() {
if (sourceMapSupportInstalled) return;
sourceMapSupportInstalled = true;

try {
const sourceMapSupport = await import("source-map-support");
sourceMapSupport.default.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
} catch (error) {
console.warn("Failed to install source-map-support:", error);
}
}

process.on("uncaughtException", function (error, origin) {
if (error instanceof Error) {
Expand Down Expand Up @@ -80,6 +91,11 @@ async function bootstrap() {

const { config } = await importConfig(buildManifest.configPath);

// Install source-map-support after config is loaded (deferred to avoid OOM with Sentry debug ID injection)
if (config.sourceMapSupport !== false) {
installSourceMapSupport();
}

// This needs to run or the PrismaInstrumentation will throw an error
const tracingSDK = new TracingSDK({
url: env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318",
Expand Down
28 changes: 22 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,28 @@ 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 { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";

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

async function installSourceMapSupport() {
if (sourceMapSupportInstalled) return;
sourceMapSupportInstalled = true;

try {
const sourceMapSupport = await import("source-map-support");
sourceMapSupport.default.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
} catch (error) {
console.warn("Failed to install source-map-support:", error);
}
}

process.on("uncaughtException", function (error, origin) {
logError("Uncaught exception", { error, origin });
Expand Down Expand Up @@ -271,6 +282,11 @@ async function doBootstrap() {
});
}

// Install source-map-support after config is loaded (deferred to avoid OOM with Sentry debug ID injection)
if (config.sourceMapSupport !== false) {
installSourceMapSupport();
}

log("Bootstrapped worker");

return {
Expand Down
28 changes: 22 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,29 @@ 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 { 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,
});
let sourceMapSupportInstalled = false;

async function installSourceMapSupport() {
if (sourceMapSupportInstalled) return;
sourceMapSupportInstalled = true;

try {
const sourceMapSupport = await import("source-map-support");
sourceMapSupport.default.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
} catch (error) {
console.warn("Failed to install source-map-support:", error);
}
}

process.on("uncaughtException", function (error, origin) {
if (error instanceof Error) {
Expand Down Expand Up @@ -80,6 +91,11 @@ async function bootstrap() {

const { config } = await importConfig(buildManifest.configPath);

// Install source-map-support after config is loaded (deferred to avoid OOM with Sentry debug ID injection)
if (config.sourceMapSupport !== false) {
installSourceMapSupport();
}

// This needs to run or the PrismaInstrumentation will throw an error
const tracingSDK = new TracingSDK({
url: env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318",
Expand Down
28 changes: 22 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,28 @@ 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 { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";

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

async function installSourceMapSupport() {
if (sourceMapSupportInstalled) return;
sourceMapSupportInstalled = true;

try {
const sourceMapSupport = await import("source-map-support");
sourceMapSupport.default.install({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
} catch (error) {
console.warn("Failed to install source-map-support:", error);
}
}

process.on("uncaughtException", function (error, origin) {
console.error("Uncaught exception", { error, origin });
Expand Down Expand Up @@ -250,6 +261,11 @@ async function doBootstrap() {
});
}

// Install source-map-support after config is loaded (deferred to avoid OOM with Sentry debug ID injection)
if (config.sourceMapSupport !== false) {
installSourceMapSupport();
}

return {
tracer,
tracingSDK,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ export type TriggerConfig = {
*/
disableConsoleInterceptor?: boolean;

/**
* Enable or disable source-map-support for enhanced stack traces.
* Disabling this can help prevent OOM issues when using Sentry's debug ID injection
* with large projects that have many bundled files.
*
* @default true
*/
sourceMapSupport?: boolean;

build?: {
/**
* Add custom conditions to the esbuild build. For example, if you are importing `ai/rsc`, you'll need to add "react-server" condition.
Expand Down