Skip to content

Conversation

@deepshekhardas
Copy link

@deepshekhardas deepshekhardas commented Feb 2, 2026

Summary

Fixes #2920

Problem

Sentry sourcemap injection adds
ew Error().stack\ to bundled modules, causing \source-map-support\ to eagerly parse sourcemaps during module loading. This leads to OOM on small machines when bundling many files.

Fix

Wrapped \sourceMapSupport.install()\ logic in \installSourceMapSupport\ utility across all worker entry points.

Introduced \TRIGGER_SOURCE_MAPS\ environment variable:

  • \TRIGGER_SOURCE_MAPS=false\ or \

Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: ed41f0a

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

This pull request refactors source map support across multiple worker entry points by centralizing configuration into a new utility module. A new installSourceMapSupport function is introduced that conditionally installs source-map-support based on the TRIGGER_SOURCE_MAPS environment variable, supporting three modes: disabled, Node's native source maps, or standard source-map-support. Additionally, uncaught exception handling is enhanced in three worker files to emit IPC events with error details to the parent process. A changeset entry documents the fix for Sentry OOM and the new environment variable control. Tests are added to verify the utility's conditional behavior across different environment variable states.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete: it references issue #2920, explains the problem and mentions the main fix, but is cut off mid-description and missing required sections like Testing and Changelog from the template. Complete the description by finishing the TRIGGER_SOURCE_MAPS environment variable documentation and filling in the Testing and Changelog sections as required by the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: allowing to disable source-map-support to prevent OOM with Sentry, which directly addresses the PR's primary objective.
Linked Issues check ✅ Passed The PR successfully addresses issue #2920's objectives: it wraps source-map-support in a utility, provides environment variable control (TRIGGER_SOURCE_MAPS), implements the config option to disable source-map-support, and enables Node's native source maps.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue #2920: utility creation, worker entry point integration, uncaught exception handling improvements, and comprehensive testing are all within scope of fixing the OOM issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View issues and 3 additional flags in Devin Review.

Open in Devin Review

Comment on lines +66 to +68
import { installSourceMapSupport } from "../utilities/sourceMaps.js";

installSourceMapSupport();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Missing imports in managed-run-worker.ts cause runtime errors

The PR removed import statements for env, normalizeImportPath, VERSION, and promiseWithResolvers from managed-run-worker.ts, but these symbols are still used in the code, causing undefined reference errors at runtime.

Click to expand

Missing imports and their usages:

  1. env (from std-env) - used at lines 177, 179:

    url: env.TRIGGER_OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318",
    diagLogLevel: (env.TRIGGER_OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
  2. normalizeImportPath (from ../utilities/normalizeImportPath.js) - used at lines 173, 449, 457:

    const { config, handleError } = await importConfig(normalizeImportPath(workerManifest.configPath));
    await import(normalizeImportPath(workerManifest.initEntryPoint));
    await import(normalizeImportPath(taskManifest.entryPoint));
  3. VERSION (from ../version.js) - used at lines 186, 187:

    const otelTracer: Tracer = tracingSDK.getTracer("trigger-dev-worker", VERSION);
    const otelLogger: Logger = tracingSDK.getLogger("trigger-dev-worker", VERSION);
  4. promiseWithResolvers (from @trigger.dev/core/utils) - used at line 626:

    const { promise, resolve } = promiseWithResolvers<void>();

Impact:

The managed worker will crash immediately when it tries to access these undefined symbols, preventing any task execution in production environments.

Recommendation: Add back the missing imports:

import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +66 to +68
import { installSourceMapSupport } from "../utilities/sourceMaps.js";

installSourceMapSupport();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Missing imports in dev-run-worker.ts cause runtime errors

The PR removed import statements for env, normalizeImportPath, VERSION, and promiseWithResolvers from dev-run-worker.ts, but these symbols are still used in the code, causing undefined reference errors at runtime.

Click to expand

Missing imports and their usages:

  1. env (from std-env) - used at lines 180, 197, 201:

    const manifestContents = await readFile(env.TRIGGER_WORKER_MANIFEST_PATH!, "utf-8");
    url: env.TRIGGER_OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318",
    diagLogLevel: (env.TRIGGER_OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
  2. normalizeImportPath (from ../utilities/normalizeImportPath.js) - used at lines 169, 457, 465:

    const configModule = await import(normalizeImportPath(configPath));
    await import(normalizeImportPath(workerManifest.initEntryPoint));
    await import(normalizeImportPath(taskManifest.entryPoint));
  3. VERSION (from ../version.js) - used at lines 206, 207:

    const otelTracer: Tracer = tracingSDK.getTracer("trigger-dev-worker", VERSION);
    const otelLogger: Logger = tracingSDK.getLogger("trigger-dev-worker", VERSION);
  4. promiseWithResolvers (from @trigger.dev/core/utils) - used at line 637:

    const { promise, resolve } = promiseWithResolvers<void>();

Impact:

The dev worker will crash immediately when it tries to access these undefined symbols, preventing any task execution in development environments.

Recommendation: Add back the missing imports:

import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/cli-v3/src/entryPoints/dev-run-worker.ts`:
- Around line 104-105: The process.title assignment uses a template literal that
includes a newline and spaces before the closing "})", producing an unintended
multiline process title; fix this in the process.title = `trigger-dev-run-worker
(${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`; statement by
moving the closing brace and backtick onto the same line as the template
expression so no newline or extra spaces are included (locate the assignment to
process.title and the getEnvVar call to update).

In `@packages/cli-v3/src/utilities/sourceMaps.test.ts`:
- Around line 2-61: The tests violate the no-mocking policy: remove
vi.mock("source-map-support") and any vi.fn() stubs for
process.setSourceMapsEnabled from
packages/cli-v3/src/utilities/sourceMaps.test.ts and instead refactor
installSourceMapSupport to accept its dependencies (e.g., a sourceMapSupport
object with an install method and an optional setSourceMapsEnabled function) or
to expose pure helper functions for the decision logic; update the tests to call
those pure functions or pass real dependency objects (or use an integration test
hitting the real source-map-support) and assert behavior without creating mocks
or spies against source-map-support or process.setSourceMapsEnabled.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ccb8c1 and ed41f0a.

📒 Files selected for processing (7)
  • .changeset/fix-sentry-oom-2920.md
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/utilities/sourceMaps.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead

**/*.{ts,tsx}: Always import tasks from @trigger.dev/sdk, never use @trigger.dev/sdk/v3 or deprecated client.defineJob pattern
Every Trigger.dev task must be exported and have a unique id property with no timeouts in the run function

Files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Import from @trigger.dev/core using subpaths only, never import from root

Files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries

Files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
{packages,integrations}/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Add a changeset when modifying any public package in packages/* or integrations/* using pnpm run changeset:add

Files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/utilities/sourceMaps.test.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use vitest for all tests in the Trigger.dev repository

Files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptive describe and it blocks
Tests should avoid mocks or stubs and use the helpers from @internal/testcontainers when Redis or Postgres are needed
Use vitest for running unit tests

**/*.test.{ts,tsx,js,jsx}: Use vitest exclusively for testing and never mock anything - use testcontainers instead
Place test files next to source files with naming pattern: source file (e.g., MyService.ts) → MyService.test.ts

Files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use testcontainers helpers (redisTest, postgresTest, containerTest) from @internal/testcontainers for Redis/PostgreSQL testing instead of mocks

Files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
🧠 Learnings (24)
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks

Applied to files:

  • .changeset/fix-sentry-oom-2920.md
  • packages/cli-v3/src/utilities/sourceMaps.ts
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Always import tasks from `trigger.dev/sdk`, never use `trigger.dev/sdk/v3` or deprecated `client.defineJob` pattern

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use logger methods (debug, log, info, warn, error) from `trigger.dev/sdk/v3` for structured logging in tasks

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Import from `trigger.dev/core` using subpaths only, never import from root

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-index-worker.ts
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Place test files next to source files with naming pattern: source file (e.g., `MyService.ts`) → `MyService.test.ts`

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest exclusively for testing and never mock anything - use testcontainers instead

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Test files should live beside the files under test and use descriptive `describe` and `it` blocks

Applied to files:

  • packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-26T14:40:07.146Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2710
File: packages/schema-to-json/package.json:0-0
Timestamp: 2025-11-26T14:40:07.146Z
Learning: Node.js 24+ has native TypeScript support and can execute .ts files directly without tsx or ts-node for scripts that use only erasable TypeScript syntax (type annotations, interfaces, etc.). The trigger.dev repository uses Node.js 24.11.1+ and scripts like updateVersion.ts can be run with `node` instead of `tsx`.

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2025-10-08T11:48:12.327Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2593
File: packages/core/src/v3/workers/warmStartClient.ts:168-170
Timestamp: 2025-10-08T11:48:12.327Z
Learning: The trigger.dev runners execute only in Node 21 and 22 environments, so modern Node.js APIs like AbortSignal.any (introduced in v20.3.0) are supported.

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Every Trigger.dev task must be exported and have a unique `id` property with no timeouts in the run function

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Use `trigger.dev/redis-worker` for background job and worker system needs in the webapp and run engine

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest dev` to start the Trigger.dev development server

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest init` to initialize a Trigger.dev project

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Specify runtime environment (node or bun) in trigger.config.ts using the `runtime` property

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use the `task()` function from `trigger.dev/sdk/v3` to define tasks with id and run properties

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/app/**/*.{ts,tsx} : Access all environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env` in the Trigger.dev webapp

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `.withStreams()` to subscribe to realtime streams from task metadata in addition to run changes

Applied to files:

  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Use the Run Engine 2.0 from `internal/run-engine` for new run lifecycle code in the webapp instead of the legacy run engine

Applied to files:

  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
🧬 Code graph analysis (3)
packages/cli-v3/src/entryPoints/dev-index-worker.ts (1)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
  • installSourceMapSupport (3-22)
packages/cli-v3/src/entryPoints/managed-index-worker.ts (1)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
  • installSourceMapSupport (3-22)
packages/cli-v3/src/entryPoints/managed-run-worker.ts (2)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
  • installSourceMapSupport (3-22)
packages/core/src/v3/schemas/build.ts (2)
  • WorkerManifest (86-111)
  • WorkerManifest (113-113)
🔇 Additional comments (6)
.changeset/fix-sentry-oom-2920.md (1)

1-5: Changeset entry is clear and sufficient.

packages/cli-v3/src/utilities/sourceMaps.ts (1)

1-21: Centralized source map setup looks good.

packages/cli-v3/src/entryPoints/dev-index-worker.ts (1)

16-23: Source map installer call is wired correctly.

packages/cli-v3/src/entryPoints/managed-run-worker.ts (1)

66-69: LGTM on the startup wiring changes.

Also applies to: 127-132, 255-262

packages/cli-v3/src/entryPoints/dev-run-worker.ts (1)

66-69: Startup wiring changes look good.

Also applies to: 150-151, 279-284

packages/cli-v3/src/entryPoints/managed-index-worker.ts (1)

16-23: Source map installer hook and keep-alive mapping look fine.

Also applies to: 167-168

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +104 to +105
process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"
})`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n packages/cli-v3/src/entryPoints/dev-run-worker.ts | sed -n '100,110p'

Repository: triggerdotdev/trigger.dev

Length of output: 453


Remove the newline and indentation from the process.title template literal.

The template literal on lines 104-105 preserves the newline and two spaces before }), which will be included literally in the process title string, resulting in an unintended multiline title. Keep the closing brace on the same line as the template expression.

🔧 Suggested fix
-process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"
-  })`;
+process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"
})`;
process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`;
🤖 Prompt for AI Agents
In `@packages/cli-v3/src/entryPoints/dev-run-worker.ts` around lines 104 - 105,
The process.title assignment uses a template literal that includes a newline and
spaces before the closing "})", producing an unintended multiline process title;
fix this in the process.title = `trigger-dev-run-worker
(${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`; statement by
moving the closing brace and backtick onto the same line as the template
expression so no newline or extra spaces are included (locate the assignment to
process.title and the getEnvVar call to update).

Comment on lines +2 to +61
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import sourceMapSupport from "source-map-support";
import { installSourceMapSupport } from "./sourceMaps.js";

vi.mock("source-map-support", () => ({
default: {
install: vi.fn(),
},
}));

describe("installSourceMapSupport", () => {
const originalEnv = process.env;
const originalSetSourceMapsEnabled = process.setSourceMapsEnabled;

beforeEach(() => {
vi.clearAllMocks();
process.env = { ...originalEnv };
// Mock setSourceMapsEnabled if it doesn't exist (Node < 16.6) or restore it
process.setSourceMapsEnabled = vi.fn();
});

afterEach(() => {
process.env = originalEnv;
process.setSourceMapsEnabled = originalSetSourceMapsEnabled;
});

it("should install source-map-support by default (undefined env var)", () => {
delete process.env.TRIGGER_SOURCE_MAPS;
installSourceMapSupport();
expect(sourceMapSupport.install).toHaveBeenCalledWith({
handleUncaughtExceptions: false,
environment: "node",
hookRequire: false,
});
});

it("should install source-map-support if env var is 'true'", () => {
process.env.TRIGGER_SOURCE_MAPS = "true";
installSourceMapSupport();
expect(sourceMapSupport.install).toHaveBeenCalled();
});

it("should NOT install source-map-support if env var is 'false'", () => {
process.env.TRIGGER_SOURCE_MAPS = "false";
installSourceMapSupport();
expect(sourceMapSupport.install).not.toHaveBeenCalled();
});

it("should NOT install source-map-support if env var is '0'", () => {
process.env.TRIGGER_SOURCE_MAPS = "0";
installSourceMapSupport();
expect(sourceMapSupport.install).not.toHaveBeenCalled();
});

it("should enable native node source maps if env var is 'node'", () => {
process.env.TRIGGER_SOURCE_MAPS = "node";
installSourceMapSupport();
expect(sourceMapSupport.install).not.toHaveBeenCalled();
expect(process.setSourceMapsEnabled).toHaveBeenCalledWith(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and read the source file being tested
find . -path "*packages/cli-v3/src/utilities/sourceMaps.ts" -o -path "*packages/cli-v3/src/utilities/sourceMaps.js" | head -5

Repository: triggerdotdev/trigger.dev

Length of output: 114


🏁 Script executed:

# Check the full CLAUDE.md and AGENTS.md for context on mocking policy
find . -name "CLAUDE.md" -o -name "AGENTS.md" | head -5

Repository: triggerdotdev/trigger.dev

Length of output: 92


🏁 Script executed:

# Search for any mocking guidance in documentation files
rg "mock|testcontainers" --type md -A 3 -B 1 | head -100

Repository: triggerdotdev/trigger.dev

Length of output: 3907


🏁 Script executed:

cat -n ./packages/cli-v3/src/utilities/sourceMaps.ts

Repository: triggerdotdev/trigger.dev

Length of output: 751


🏁 Script executed:

# Check if there are any other test files in the repo that mock third-party libraries to understand the policy scope
rg "vi\.mock|vi\.spyOn" --type ts -l packages/ | head -10

Repository: triggerdotdev/trigger.dev

Length of output: 286


🏁 Script executed:

# Check one of these other test files to see if they also mock, and if so, whether this is a systemic issue or expected
cat -n packages/core/src/v3/serverOnly/shutdownManager.test.ts | head -80

Repository: triggerdotdev/trigger.dev

Length of output: 3373


🏁 Script executed:

# Search for any tests that DON'T mock to understand how they structure tests for external dependencies
rg "describe\(" packages/cli-v3/src/utilities/sourceMaps.test.ts -A 30 | head -50

Repository: triggerdotdev/trigger.dev

Length of output: 1179


🏁 Script executed:

# Check if there are any recent commits or guidance about this specific test file
git log --oneline packages/cli-v3/src/utilities/sourceMaps.test.ts | head -5

Repository: triggerdotdev/trigger.dev

Length of output: 160


🏁 Script executed:

# Check if there are any tests in the repo that test source-map behavior without mocking
rg "source-map|sourceMap" --type ts packages/ | grep -E "\.test\.|\.spec\." | head -10

Repository: triggerdotdev/trigger.dev

Length of output: 1205


🏁 Script executed:

# Look for any test files that might show patterns for testing environment-dependent code
rg "process\.env" --type ts packages/*/src/**/*.test.ts | head -10

Repository: triggerdotdev/trigger.dev

Length of output: 820


Remove all mocking from this test file; this violates the repository's explicit "never mock anything" policy.

The test uses vi.mock("source-map-support") and vi.fn() to stub process.setSourceMapsEnabled, which directly contradicts the repository's documented testing standards. Per CLAUDE.md and ai/references/tests.md, mocking, spying, and stubbing are forbidden in tests.

Refactor installSourceMapSupport to be more testable without mocks—for example, by extracting the logic into separate, pure functions that can be tested with real values, or by redesigning the function to accept dependencies as parameters. Alternatively, if testing the actual behavior of source-map-support is necessary, consider writing an integration test that exercises the real module without mocks.

🤖 Prompt for AI Agents
In `@packages/cli-v3/src/utilities/sourceMaps.test.ts` around lines 2 - 61, The
tests violate the no-mocking policy: remove vi.mock("source-map-support") and
any vi.fn() stubs for process.setSourceMapsEnabled from
packages/cli-v3/src/utilities/sourceMaps.test.ts and instead refactor
installSourceMapSupport to accept its dependencies (e.g., a sourceMapSupport
object with an install method and an optional setSourceMapsEnabled function) or
to expose pure helper functions for the decision logic; update the tests to call
those pure functions or pass real dependency objects (or use an integration test
hitting the real source-map-support) and assert behavior without creating mocks
or spies against source-map-support or process.setSourceMapsEnabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Sentry debug ID injection causes OOM during module loading

1 participant