fix(core): use zod/v4 for the snapshot route schema so warm starts work on zod 3 projects - #4972
Conversation
…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 detectedLatest commit: 1906c00 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
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 |
|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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)
🧰 Additional context used📓 Path-based instructions (7)**Public packages** (`packages/*`): Use `build`.📄 CodeRabbit inference engine (AGENTS.md) Files:
Use zod for validation in packages/core and apps/webapp📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Never import the root package (`@trigger.dev/core`).📄 CodeRabbit inference engine (packages/core/CLAUDE.md) Files:
Use vitest for all tests in the Trigger.dev repository📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use function declarations instead of default exports📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
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:
🧠 Learnings (1)📚 Learning: 2026-06-16T09:19:47.637ZApplied to files:
🔇 Additional comments (3)
WalkthroughThe snapshot-route schemas now import Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to 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)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
Deployments built with 4.6.0 to 4.6.3 in projects where
zodresolves 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.tslanded shortly after, still importing the Zod 3 API from"zod", andSnapshotRouteWireis composed intoDequeuedMessageand the worker attempt request bodies. Zod 4 rejects a Zod 3 schema inside a Zod 4 object at parse time, regardless of the input:Inside the monorepo the root
zodresolves to 4.x, so nothing failed here. In a user's image with zod 3.x installed, the warm-start client'sDequeuedMessage.parse()threw on every run and the controller exited.Fix
One import:
snapshotRoute.tsnow useszod/v4. The existing Zod 3 root compatibility test gains a case that bundlesDequeuedMessageandWorkerApiRunAttemptStartRequestBodyagainst a Zod 3 root and parses them; it fails onmainand passes here. Also verified by packing the built package and parsing aDequeuedMessagewithzod@3.25.76installed.