Repository navigation
fix(runtime): stop failover and keep the transport error when shouldRetry fails - #12
Merged
Merged
Conversation
This was referenced Dec 2, 2026
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.
Problem
recoveryPolicy.shouldRetryis awaited inside the attempt'scatchblock with no error handling of its own (src/runtime/runtime.ts). If the callback throws or rejects (for example, because the receipt lookup it awaits fails), two things go wrong:TransportError. That dropscodeandstatus, which tell the caller whether the operation may already have run.recovery.decidedis never emitted. The events end atattempt.failed, although the docs say "recovery.decidedrecords the choice".A receipt store being briefly unavailable is exactly the situation
shouldRetryexists for, so this path is likely in practice.Change
shouldRetrynow counts as "do not retry". The Runtime emitsrecovery.decidedwithdecision: "stop"and rethrows the originalTransportError. The reasoning: a safety check that could not finish has not shown that replay is safe.RecoveryPolicydoc comment and the failover paragraph indocs/worker-communication.mdand.zh-CN.md.test/runtime-failover.test.ts, covering both a synchronous throw and a rejected promise. It checks the rejected error is the originalTIMEOUT/outcome_unknownTransportErrorfor the first attempt, that there is no second dispatch, and that the events end withrecovery.decided/stop.Open question
The callback's own error is not passed on: the application can log it inside its callback, as with
onExecutionEventobservers. If you'd rather surface it, I can attach it to therecovery.decidedevent or wrap both errors. I keptTransportErroras the thrown type soinstanceofandstatuschecks keep working.Validation
Run with
npm run checkon Windows 11, Node 24.14.0, on top ofdevatf0e5297:runtime.tschange reverted, it fails: the caller getsError: receipt store unavailable.EPERM×2, the sandbox environment-key assertion, and the capability-boundary audit). They also fail on unmodifieddev, and none touches the files changed here.