fix(api): retain commands after ambiguous Queue sends#299
Conversation
|
All contributors on this pull request have signed the CLA. |
|
I have read the CLA Document and I hereby sign the CLA |
Yevanchen
left a comment
There was a problem hiding this comment.
Reviewed with full codebase context. Verified the outbox design end to end: consumer claim CAS + ack-on-claim-miss makes duplicate redrive sends safe; the marker-clear update is guarded by status='queued' plus a marker whitelist so it cannot clobber real retry errors written by releaseApiCommandForRetry; the only production reader of api_command.lastErrorCode (deployment recoverMissingDispatch) also requires attemptCount >= max, so the new pending marker cannot fail runs prematurely. Session-run latency is unaffected thanks to the inline waitUntil dispatch; with the 1-minute cron, redrive latency is bounded and the LIMIT 100 scan is covered by the (status, updated_at) index. Tests exercise the real scheduled handler and dispatch path. LGTM.
Summary
queue_delivery_pendingmarker before attempting Queue delivery.Why
A producer-side timeout can occur after Cloudflare Queue has accepted a message. The original path deleted the command record. The first revision retained that record but still threw to App deployment, which marked the DeploymentRun failed before a delivered or redriven command could execute. The durable outbox must be the acceptance boundary, not the synchronous Queue response.
Verification
just test-file apps/api/tests/api-command-queue.test.ts(6 passing);just test-file apps/api/tests/app-deployment-service.test.ts(19 passing);just tc-package @mosoo/api;just commit-check;just check(942 passing tests, plus format, docs, lint, type, and GraphQL checks).queuedinstead of becomingfailedwhen Queue delivery is deferred.Impact
Review