From af9616f47d87f317d5bc07b90015b3bdaee7524c Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:12:58 +0800 Subject: [PATCH] test: let the wedged-worker regression post its child-start first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The regression's script spun immediately after calling agent(), but the agent() continuation (which posts the child-start RPC) only runs on a microtask tick — the spin seized the worker's loop before the post, so the host never saw a child inside the waitFor window. A few await-null yields before the spin let the RPC out; the posted message needs no further worker-loop turns to reach the host, so the wedge still holds for the Cancel message the test is about. --- .../tests/workflow-workerthread.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts b/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts index 9e2218c167..20911d052e 100644 --- a/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts +++ b/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts @@ -511,9 +511,13 @@ describe('dsh-workflow-workerthread', () => { // The stray child's start RPC reaches the host, then the script wedges // its own worker in a synchronous spin: the worker cannot process the // Cancel message, so it can relay NO ChildCancel RPC — only the host's - // own children loop can deliver the explicit cancel in time. + // own children loop can deliver the explicit cancel in time. The + // microtask yields let the agent() continuation POST its child-start + // before the spin seizes the worker's loop (the posted message needs + // no further worker-loop turns to reach the host). script: script(` agent('wedged child') + for (let i = 0; i < 20; i++) await null const end = Date.now() + 1500 while (Date.now() < end) {} return 'raced'