Skip to content

Conversation

@deepshekhardas
Copy link

@deepshekhardas deepshekhardas commented Feb 2, 2026

Summary

Fixes #2796

Problem

When a task's machine configuration was removed and the project redeployed, runs would still execute on the old machine preset instead of resetting to the default (small-1x).

Root Cause

In sharedQueueConsumer.server.ts, the code was prioritizing existingTaskRun.machinePreset (stale value) over the current deployment's backgroundTask.machineConfig.

Fix

Changed machine preset resolution to always use current deployment's machine config.


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: a334205

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 adds a patch release changelog entry and modifies the machine preset resolution logic in the shared queue consumer. The key functional change updates how the machinePreset is calculated in the Execute path to always derive from the background task's current machineConfig instead of falling back to a previously used machine preset from an existing task run. This ensures deployments correctly use their current configuration when machine presets have been removed. Additionally, minor formatting adjustments were made to empty finally handlers and indentation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers the problem, root cause, and fix, but is missing testing steps and changelog sections from the template. Add the Testing section describing how the fix was validated, and complete the Changelog section with a brief summary of changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main fix: ensuring machine preset resets to default when machine config is removed.
Linked Issues check ✅ Passed The PR directly addresses issue #2796 by fixing the machine preset logic to use current deployment's config instead of stale values.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the machine preset resolution logic and related formatting adjustments; no out-of-scope changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

📜 Recent 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 a334205.

📒 Files selected for processing (2)
  • .changeset/fix-machine-preset-reset.md
  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{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:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}

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

Use zod for validation in packages/core and apps/webapp

Files:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.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:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
apps/webapp/app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Access all environment variables through the env export of env.server.ts instead of directly accessing process.env in the Trigger.dev webapp

Files:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

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
Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Access environment variables via env export from apps/webapp/app/env.server.ts, never use process.env directly

Files:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.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:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
🧠 Learnings (5)
📓 Common learnings
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 : Set default machine configuration in trigger.config.ts using `defaultMachine` property
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} : Specify machine resources using the `machine` property with preset options like 'large-1x'
📚 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} : Specify machine resources using the `machine` property with preset options like 'large-1x'

Applied to files:

  • .changeset/fix-machine-preset-reset.md
  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
📚 Learning: 2025-01-13T18:31:48.160Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 1608
File: apps/webapp/app/v3/services/triggerTask.server.ts:418-418
Timestamp: 2025-01-13T18:31:48.160Z
Learning: The `MachinePresetName` schema is used to validate machine preset values in the trigger.dev codebase, ensuring type safety and validation of machine preset options.

Applied to files:

  • .changeset/fix-machine-preset-reset.md
📚 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 : Set default machine configuration in trigger.config.ts using `defaultMachine` property

Applied to files:

  • .changeset/fix-machine-preset-reset.md
📚 Learning: 2025-06-04T16:02:22.957Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2150
File: apps/supervisor/src/workloadManager/docker.ts:115-115
Timestamp: 2025-06-04T16:02:22.957Z
Learning: In the Trigger.dev codebase, the supervisor component uses DOCKER_ENFORCE_MACHINE_PRESETS while the docker provider component uses ENFORCE_MACHINE_PRESETS. These are separate components with separate environment variable configurations for the same logical concept of enforcing machine presets.

Applied to files:

  • .changeset/fix-machine-preset-reset.md
🧬 Code graph analysis (1)
apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts (4)
apps/webapp/app/v3/models/workerDeployment.server.ts (2)
  • getWorkerDeploymentFromWorker (244-267)
  • findCurrentWorkerDeployment (73-161)
apps/webapp/app/v3/machinePresets.server.ts (1)
  • machinePresetFromConfig (5-25)
packages/core/src/v3/schemas/schemas.ts (2)
  • V3ProdTaskRunExecution (45-53)
  • V3ProdTaskRunExecution (55-55)
packages/core/src/v3/schemas/common.ts (2)
  • TaskRunExecutionResult (515-518)
  • TaskRunExecutionResult (520-520)
🔇 Additional comments (6)
.changeset/fix-machine-preset-reset.md (1)

1-7: LGTM!

The changeset clearly documents the behavioral fix. The description accurately captures the root cause and the solution, which aligns with the code changes in sharedQueueConsumer.server.ts.

apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts (5)

265-265: LGTM!

The empty .finally() handler is an acceptable pattern here to prevent unhandled promise rejection warnings on this fire-and-forget call to #doWork().


419-421: LGTM!

Consistent with the pattern at line 265 for the background work loop continuation.


619-628: LGTM!

The indentation change improves readability of this ternary chain. The deployment resolution logic correctly prioritizes locked tasks/versions before falling back to the current deployment.


720-727: LGTM! Core fix for issue #2796.

The change correctly derives machinePreset from the current deployment's backgroundTask.machineConfig rather than using a potentially stale value from the existing run. When machine config is removed (backgroundTask.machineConfig is null), passing {} to machinePresetFromConfig will return the default "small-1x" preset.

The updated value is persisted at line 744 and subsequent reads via machinePresetFromRun(lockedTaskRun) (e.g., line 913) will use this correctly computed value.


1901-1906: LGTM!

Formatting-only change to the return type definition.

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


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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

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

@nicktrn nicktrn closed this Feb 3, 2026
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.

Removing the machine from a task doesn't set it back to default when deploying

2 participants