Title: 4.6.0+ with zod ≥ 4.4: every run completion waits a fixed 6 s (cancels 31 s) because FLUSH/CANCEL IPC acks are rejected · Issue #4979 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: 4.6.0+ with zod ≥ 4.4: every run completion waits a fixed 6 s (cancels 31 s) because FLUSH/CANCEL IPC acks are rejected · Issue #4979 · triggerdotdev/trigger.dev
X Title: 4.6.0+ with zod ≥ 4.4: every run completion waits a fixed 6 s (cancels 31 s) because FLUSH/CANCEL IPC acks are rejected · Issue #4979 · triggerdotdev/trigger.dev
Description: What happens Since 4.6.0, in projects that resolve zod to 4.4 or newer, every run on a managed worker takes ~6.1 s longer between the task finishing and the completion reaching the engine. Compute (usage_duration) is unchanged; execution...
Open Graph Description: What happens Since 4.6.0, in projects that resolve zod to 4.4 or newer, every run on a managed worker takes ~6.1 s longer between the task finishing and the completion reaching the engine. Compute ...
X Description: What happens Since 4.6.0, in projects that resolve zod to 4.4 or newer, every run on a managed worker takes ~6.1 s longer between the task finishing and the completion reaching the engine. Compute ...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/4979
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"4.6.0+ with zod ≥ 4.4: every run completion waits a fixed 6 s (cancels 31 s) because FLUSH/CANCEL IPC acks are rejected","articleBody":"**What happens**\n\nSince 4.6.0, in projects that resolve `zod` to 4.4 or newer, every run on a managed worker takes ~6.1 s longer between the task finishing and the completion reaching the engine. Compute (`usage_duration`) is unchanged; `execution_duration - usage_duration` goes from ~0.1–0.25 s on 4.5.15 to 6.10–6.29 s on 4.6.0 and 4.6.2, for every task, warm or cold. Cancellation is hit harder: the CANCEL ack budget is 30 s + 1 s. Still present on `main` (c2b7a72) and in 4.6.4: `zodIpc.ts` is unchanged since #4039.\n\nWe see it on every task we run: the gap appears exactly at the SDK upgrade and never drops below ~6.09 s, where it was ~0.1 s before.\n\n**Why**\n\n`TaskRunProcess.cleanup()` sends `FLUSH` to the task run process with `sendWithAck(..., timeoutInMs + 1_000)` (5 s + 1 s) before `completeRunAttempt`. `FLUSH` and `CANCEL` declare `callback: z.void()`, so the child acks with `{ type: \"ACK\", id, message: undefined }`. `process.send` JSON-serialises the packet and drops the `message` key. In `zodIpc.ts` the `Packet` schema declares `message: z.any()`; under zod 3 a `z.any()` key was optional at parse time, under zod 4.4+ it is required (see the version table below). Since #4039, `zodIpc.ts` imports `zod/v4`, and `@trigger.dev/core` usually resolves `zod` from the user's project (`^3.25.56 || ^4.0.0`). So any project that resolves zod 4.4 or newer (this repo pins 4.5.4) fails `Packet.safeParse` on every ack, `#handlePacket` returns silently, and `sendWithAck` waits out its full timeout. Nothing is logged because the rejection is swallowed by `tryCatch`.\n\n**Repro (zod alone)**\n\n```\nzod 4.6.5: z.discriminatedUnion(\"type\", [...ACK { message: z.any(), id }]).safeParse({ type: \"ACK\", id: 0 })\n -> message: Invalid input: expected nonoptional, received undefined\n```\n\nThe same schema across versions (root `zod` and `zod/v4` behave the same):\n\n```\nzod 3.25.76 accepted\nzod 4.3.6 accepted\nzod 4.4.0 REJECTED\nzod 4.5.4 REJECTED\n```\n\nThat is probably why this has gone unreported: projects on zod 3.x or 4.0–4.3 are unaffected, and billed compute (`usage_duration`) does not change.\n\n**Repro (two ZodIpcConnections over a forked child, 3 s ack timeouts)**\n\n```\ncore 4.6.2: FLUSH: REJECTED after 3002ms (sendWithAck() timeout) CANCEL: REJECTED after 3001ms\ncore 4.5.15: FLUSH: ack in 2ms CANCEL: ack in 0ms\n```\n\n**End-to-end confirmation (trigger dev, same server, same one-task project, six runs each)**\n\n| worker | task compute | gap between task end and completion |\n|---|---|---|\n| stock `trigger.dev@4.6.2` | 14 ms | 6.27 – 6.34 s |\n| same install, only `message: z.any().optional()` on the ACK packet in core's dist | 14 ms | 0.40 – 0.46 s |\n\nThe dev controller runs the same `TaskRunProcess.cleanup()` → `FLUSH` → `completeRunAttempt` sequence as the managed controller, and that line is the only change between the two workers.\n\n**Fix**\n\nMake the ACK packet's `message` optional again (`z.any().optional()`), which restores the zod 3 type and runtime behaviour. Only the ACK packet can legitimately carry `undefined` (the two void callbacks); no message catalog entry has an undefined payload, so the `messageSchema.payload: z.unknown()` envelope is unaffected. Happy to open a PR with this change and a JSON-round-trip test that fails on `main` and passes with the fix.\n","author":{"url":"https://github.com/marcus-dk","@type":"Person","name":"marcus-dk"},"datePublished":"2026-09-25T11:15:09Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/4979"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0b7bda7a-fb45-485e-047a-798f0128e8ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE84:137FBB:4D53FBA:67DCC04:6AFAF07F |
| html-safe-nonce | a2c3651a77810f39521ac6a0c6693fce2be97fad2f68d4dfad1bc569ee6d3c3b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTg0OjEzN0ZCQjo0RDUzRkJBOjY3RENDMDQ6NkFGQUYwN0YiLCJ2aXNpdG9yX2lkIjoiNDg3MTQxODI3MDQ1NzcyMDk1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2a4216242aa3c7643e9c74134ce49602585e0e00ffa7e0c6610ff5db55e2ab6d |
| hovercard-subject-tag | issue:5582023528 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/4979/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d73b1b4f9e5d18b65a7b425e44b0afc60852b8e5997d153e1183f91a9809c132/triggerdotdev/trigger.dev/issues/4979 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d73b1b4f9e5d18b65a7b425e44b0afc60852b8e5997d153e1183f91a9809c132/triggerdotdev/trigger.dev/issues/4979 |
| og:image:alt | What happens Since 4.6.0, in projects that resolve zod to 4.4 or newer, every run on a managed worker takes ~6.1 s longer between the task finishing and the completion reaching the engine. Compute ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | marcus-dk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 12fff95459b24b0f882a66698ee6a36a5934d247 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width