-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(core): accept IPC acks for void callbacks under zod 4.4+ #4980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NERLOE
wants to merge
4
commits into
triggerdotdev:main
Choose a base branch
from
NERLOE:fix/zod-ipc-ack-optional-message
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5892ebf
fix(core): accept IPC acks for void callbacks under zod 4.4+
NERLOE d098714
test(core): drop the timing assertion from the zodIpc ack test
NERLOE 41287e7
test(core): exercise zodIpc acks over a real forked child
NERLOE 42f254f
Make it clear billed usage wasn't impacted for the release notes
matt-aitken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| 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. Run cost and billed usage was not impacted by this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { z } from "zod/v4"; | ||
|
|
||
| export const ParentToChild = { | ||
| FLUSH: { | ||
| message: z.object({ timeoutInMs: z.number() }), | ||
| callback: z.void(), | ||
| }, | ||
| PING: { | ||
| message: z.object({ value: z.string() }), | ||
| callback: z.object({ echoed: z.string() }), | ||
| }, | ||
| }; | ||
|
|
||
| export const ChildToParent = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { ZodIpcConnection } from "../../src/v3/zodIpc.js"; | ||
| import { ChildToParent, ParentToChild } from "./zodIpcCatalog.js"; | ||
|
|
||
| // Forked by zodIpc.test.ts: answers the parent's messages over the real IPC channel. | ||
| new ZodIpcConnection({ | ||
| listenSchema: ParentToChild, | ||
| emitSchema: ChildToParent, | ||
| process, | ||
| handlers: { | ||
| FLUSH: async () => {}, | ||
| PING: async ({ value }) => ({ echoed: value }), | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { fork, type ChildProcess } from "node:child_process"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { afterEach, describe, expect, it } from "vitest"; | ||
| import { ZodIpcConnection } from "../src/v3/zodIpc.js"; | ||
| import { ChildToParent, ParentToChild } from "./fixtures/zodIpcCatalog.js"; | ||
|
|
||
| const childPath = fileURLToPath(new URL("./fixtures/zodIpcChild.ts", import.meta.url)); | ||
|
|
||
| let child: ChildProcess | undefined; | ||
|
|
||
| afterEach(() => { | ||
| child?.kill(); | ||
| child = undefined; | ||
| }); | ||
|
|
||
| // Node's default IPC serialization is JSON, so an ack with `message: undefined` | ||
| // arrives without the `message` key, exactly as it does between a worker and its task run process. | ||
| function forkChild() { | ||
| child = fork(childPath, { execArgv: ["--import", "tsx"], stdio: "inherit" }); | ||
|
|
||
| return new ZodIpcConnection({ | ||
| listenSchema: ChildToParent, | ||
| emitSchema: ParentToChild, | ||
| process: child, | ||
| }); | ||
| } | ||
|
|
||
| describe("ZodIpcConnection", () => { | ||
| it("resolves sendWithAck for a void callback", async () => { | ||
| const connection = forkChild(); | ||
|
|
||
| await expect(connection.sendWithAck("FLUSH", { timeoutInMs: 1000 }, 2000)).resolves.toBe( | ||
| undefined | ||
| ); | ||
| }); | ||
|
|
||
| it("resolves sendWithAck with the callback payload", async () => { | ||
| const connection = forkChild(); | ||
|
|
||
| await expect(connection.sendWithAck("PING", { value: "hello" }, 2000)).resolves.toEqual({ | ||
| echoed: "hello", | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.