Skip to content

fix(core): use zod/v4 for the snapshot route schema so warm starts work on zod 3 projects - #4972

Merged
carderne merged 1 commit into
mainfrom
fix/core-snapshot-route-zod-v4
Sep 22, 2026
Merged

carderne merged 1 commit into
mainfrom
fix/core-snapshot-route-zod-v4

Conversation

@d-cs

@d-cs d-cs commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Deployments built with 4.6.0 to 4.6.3 in projects where zod resolves to a 3.x release could not warm start. Every run handed to a warm runner made the runner exit before it started the attempt; the run then waited until the platform's heartbeat redrive requeued it and it started cold, a few minutes late. Cold starts were unaffected, which is why this surfaced as delayed starts rather than errors.

Root cause

The zod v4 migration (#4039) moved core's schemas to zod/v4. snapshotRoute.ts landed shortly after, still importing the Zod 3 API from "zod", and SnapshotRouteWire is composed into DequeuedMessage and the worker attempt request bodies. Zod 4 rejects a Zod 3 schema inside a Zod 4 object at parse time, regardless of the input:

Invalid element at key "snapshotRoute": expected a Zod schema

Inside the monorepo the root zod resolves to 4.x, so nothing failed here. In a user's image with zod 3.x installed, the warm-start client's DequeuedMessage.parse() threw on every run and the controller exited.

Fix

One import: snapshotRoute.ts now uses zod/v4. The existing Zod 3 root compatibility test gains a case that bundles DequeuedMessage and WorkerApiRunAttemptStartRequestBody against a Zod 3 root and parses them; it fails on main and passes here. Also verified by packing the built package and parsing a DequeuedMessage with zod@3.25.76 installed.

…rk on zod 3 projects

The snapshot route schema was created with the Zod 3 API and composed into
Zod 4 objects (DequeuedMessage and the worker attempt request bodies). When a
project resolves "zod" to a 3.x release, Zod 4 rejects the composed schema at
parse time, so the runner's warm-start client threw on every dispatched run
and exited. The run then waited for the heartbeat redrive before starting
cold. Extends the Zod 3 root compatibility test to cover these schemas.
@changeset-bot

changeset-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1906c00

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

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/core Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@internal/tracing Patch
@internal/webhook-engine Patch
@internal/webhook-sources Patch
@internal/dashboard-agent Patch
@internal/cache Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/sso Patch
@internal/testcontainers Patch

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

@d-cs
d-cs marked this pull request as draft September 22, 2026 16:25

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

Copy link
Copy Markdown
Contributor

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 bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5bf0ce57-d25f-4e26-8fcd-f67c136ff5b8

📥 Commits

Reviewing files that changed from the base of the PR and between 562c943 and 1906c00.

📒 Files selected for processing (3)
  • .changeset/snapshot-route-zod-v4.md
  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (30)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (7)
**Public packages** (`packages/*`): Use `build`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts
Use zod for validation in packages/core and apps/webapp

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

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts
Never import the root package (`@trigger.dev/core`).

📄 CodeRabbit inference engine (packages/core/CLAUDE.md)

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts
Use vitest for all tests in the Trigger.dev repository

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

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
Use function declarations instead of default exports

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

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead

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

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.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 metr...

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

Files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
  • packages/core/src/v3/schemas/snapshotRoute.ts
🧠 Learnings (1)
📚 Learning: 2026-06-16T09:19:47.637Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3960
File: apps/webapp/test/prismaInfrastructureErrorCapture.test.ts:0-0
Timestamp: 2026-06-16T09:19:47.637Z
Learning: In this repo’s Vitest setup, `vitest.config.ts` uses `globals: true`, so identifiers like `vi`, `describe`, `it`, and `expect` are available as globals in Vitest test files. During code review, do not flag missing `vi`/`describe`/`it`/`expect` imports as a runtime error or correctness issue when they’re used in `*.test.ts/tsx` or `*.spec.ts/tsx` files. Explicit imports are still preferred for consistency, but they’re not required for runtime behavior.

Applied to files:

  • packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts
🔇 Additional comments (3)
packages/core/src/v3/schemas/snapshotRoute.ts (1)

1-1: LGTM!

packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts (1)

95-172: LGTM!

.changeset/snapshot-route-zod-v4.md (1)

1-5: LGTM!


Walkthrough

The snapshot-route schemas now import zod/v4. A compatibility test bundles and parses worker schemas with Zod 3 and Zod 4 mappings. A patch changeset documents the warm-start parsing fix for affected deployments.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 1906c

Affected warm starts should parse correctly across supported Zod versions, with no remaining merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: using zod/v4 for the snapshot route schema to fix warm starts for projects using Zod 3.
Description check ✅ Passed The description clearly explains the affected versions, root cause, fix, and validation. It does not follow every template section, because it omits the issue reference, checklist, and explicit Testin…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@carderne
carderne marked this pull request as ready for review September 22, 2026 16:51
@carderne
carderne added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 21146b1 Sep 22, 2026
126 checks passed
@carderne
carderne deleted the fix/core-snapshot-route-zod-v4 branch September 22, 2026 17:15
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.

2 participants