Repository navigation
fix(rivetkit): drop a queued ActorConn action when its signal aborts - #6030
sAchin-680 wants to merge 2 commits into
Conversation
`ActorConnRaw.action()` already took a `signal` option but never actually used it. While a connection is reopening, actions sit in a queue and get sent once it's back, even if the caller has already given up (and maybe retried somewhere else). So the same action could end up running late, or twice. Now the signal is respected: - If it's already aborted, the call rejects with `signal.reason` and nothing gets queued. - If it aborts while the action is still waiting in the queue, the message is pulled out and never sent. - If it aborts after the message went out, only the caller's promise rejects. The action may still run on the actor, so its response is quietly ignored when it comes back. Closes rivet-dev#6010
575791f to
6ee9d89
Compare
|
Looks good—no high-confidence issues found in the cancellation logic or accompanying documentation. No issues found. Checked for bugs and CLAUDE.md compliance; no Review limited to the local diff and surrounding code; GitHub PR metadata was unavailable because CLI authentication was not configured. Copy prompt to fix all |
|
Hey @NathanFlurry, this PR makes @creatifcoding thanks for the clear write-up on the issue. |
Adds a short "Timeouts and Cancellation" section to the actions page. It shows how to pass a `signal` to `.action()` on handles and connections, what happens when it aborts, and links to the existing section on canceling work inside the actor.
|
thank you, but this will be superseded as we found it to be a general problem in ts, rust and swift sdk. a patch will release soon! |
Closes #6010
ActorConnRaw.action()already acceptedsignalin its options type but ignored it. While a connection reopens, an action waits in the message queue and is sent after the reopen. A caller with its own deadline (an HTTP request timing out, an interrupted Effect) may already have given up and retried elsewhere, so the queued action could run late or twice.The signal is now honoured:
action()rejects withsignal.reason. Nothing is queued or sent.signal.reason, so it is never sent after the reopen. Other queued actions are unaffected.No in flight response.For a deadline, use
signal: AbortSignal.timeout(ms)rather than a separatetimeoutoption.Also adds a short "Timeouts and Cancellation" section to the actions docs showing how to pass a
signalon handles and connections.Notes
@rivetkit/effectneeds no change. It calls actions throughActorHandle(HTTP) and already passes the fiber's abort signal (packages/effect/src/Client.ts).guard.service_unavailable), the close handler already rejects every queued action via#rejectPendingPromises. So actions currently stay queued only between retry attempts, during an attempt that succeeds, or during an attempt that hangs until the connect timeout. This change matters in those windows. It also composes with fix(rivetkit): reconnect on depot.unavailable instead of giving up #5998, which only toucheslifecycle-errors.ts.Testing
tsc --noEmitpasses and Biome is clean for the changed file. I couldn't find client unit tests in the repo to extend, so I verified with a temporary vitest suite (13 cases) that drivesActorConnRawwith a fake driver and WebSocket. It covers each case above, plus:onOpenhandler just before the queue flushesAll 13 pass, with no unhandled rejections. Against the previous code, 9 fail; the other 4 check no-op cases. I'm happy to add the suite to the repo if you point me to where client tests should live.