Fix deferred self-completion in the memory workflow engine - #8229
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 7e54e80 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 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 |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
tim-smart
force-pushed
the
agent/bob/ccc6a0c37ba5
branch
from
September 14, 2026 03:29
bb9feb3 to
7e54e80
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a workflow races a durable deferred await against a sibling that completes it through
DurableDeferred.into, the memory engine can deadlock. The sibling's uninterruptible finalizer joins the workflow fiber, which is waiting for that finalizer to finish. Both successful and failed completion are affected.Persist the result before scheduling wake-up, and fork interrupt-and-resume into the engine scope when the caller's
WorkflowInstancehas the target execution ID. This releases the finalizer while the wake still waits for old-run cleanup before requesting replay. External callers retain synchronous cleanup waiting.Adapted from the v3 fix in #8195 for v4's memory engine. Includes an
effectpatch changeset.Closes EFF-1368
Two in-process
it.liveregressions cover self-completion:start-1, cleanup-start, cleanup-end, end-1, start-2, end-2and the successful result.Both producers wait until the deferred await is registered. The tests use the live clock for workflow retry delays and a five-second Vitest timeout. If the deadlock returns, Effect cancellation cannot finish the uninterruptible finalizer; Vitest still fails the test, and its cleanup hook can also time out. Stuck fibers may remain until the worker is disposed. This trades the subprocess harness's hard cleanup boundary for simpler tests. In-process probes against the pre-fix engine confirmed that both regressions time out and the runner continues and exits with failure.
The subprocess harness and fixture are removed. The existing 15 main engine tests and the implementation are unchanged by this test refactor.
Validation:
WorkflowEngine.test.ts: 17/17 pass on Deno and Bun.nix develop -c pnpm lint-fix,nix develop -c pnpm check, andgit diff --checkpass.Focused command:
nix develop -c pnpm test --run packages/effect/test/unstable/workflow packages/effect/test/cluster/ClusterWorkflowEngine.test.ts.