Commit 8f15fa5
fix(core): accept IPC acks for void callbacks under zod 4.4+ (#4980)
Closes #4979
Credit to @marcus-dk for finding and root-causing this in #4979,
including the zod version bisect and the end-to-end confirmation with a
patched worker.
## Summary
`FLUSH` and `CANCEL` declare `callback: z.void()`, so the task run
process acks them with `{ type: "ACK", id, message: undefined }`. Node's
JSON IPC serialization drops the undefined `message` key. Under zod 4.4+
a `z.any()` object key is required at parse time (it was optional under
zod 3 and 4.0–4.3), so `Packet.safeParse` rejects every such ack,
`#handlePacket` returns silently, and `sendWithAck` waits out its full
timeout.
Because `zodIpc.ts` imports `zod/v4` and `@trigger.dev/core` resolves
`zod` from the user's project, every project on zod ≥ 4.4 pays this on
every run: ~6 s between the task finishing and the completion reaching
the engine (FLUSH: 5 s + 1 s), and ~31 s on cancel.
The fix makes the ACK packet's `message` optional again
(`z.any().optional()`). Only the ACK packet can legitimately carry
`undefined`, so the other packets are unchanged.
## ✅ Checklist
- [x] I have followed every step in the [contributing
guide](https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md)
- [x] The PR title follows the convention.
- [x] I ran and tested the code works
---
## Testing
- Added `packages/core/test/zodIpc.test.ts`: forks a real child process
(`test/fixtures/zodIpcChild.ts`) and sends `FLUSH` (void callback) and
`PING` (payload callback) over Node's IPC channel, so the ack goes
through the same JSON serialization as between a worker and its task run
process. On `main` (zod 4.5.4 in this repo) the void-callback test fails
with `sendWithAck() timeout`; with the fix it resolves immediately.
- `pnpm run build --filter @trigger.dev/core` passes.
- Production evidence from our self-hosted instance (`completed_at -
started_at - usage_duration_ms` on successful runs):
| SDK | runs | p10 gap | p50 gap |
|---|---|---|---|
| 4.5.12 | 2.6M | 179 ms | 244 ms |
| 4.5.15 | 5.0M | 176 ms | 251 ms |
| 4.6.0 | 1.6M | 6,162 ms | 6,196 ms |
| 4.6.2 | 4.0M | 6,180 ms | 6,240 ms |
---
## Changelog
Fix a ~6 second delay between a task finishing and its run completing
(and a ~31 second delay when cancelling a run) in projects that use zod
4.4 or newer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Matt Aitken <matt@mattaitken.com>1 parent ad005a4 commit 8f15fa5
5 files changed
Lines changed: 79 additions & 1 deletion
File tree
- .changeset
- packages/core
- src/v3
- test
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments