Skip to content

fix(channels): retain final-delivery jobs after Queue send failure - #308

Draft
AsperforMias wants to merge 2 commits into
langgenius:mainfrom
AsperforMias:fix/channel-final-delivery-outbox
Draft

fix(channels): retain final-delivery jobs after Queue send failure#308
AsperforMias wants to merge 2 commits into
langgenius:mainfrom
AsperforMias:fix/channel-final-delivery-outbox

Conversation

@AsperforMias

Copy link
Copy Markdown
Collaborator

Closes #303.

Summary

  • Persist a durable final-delivery ledger row before attempting Queue dispatch.
  • Retain the row when Queue send() rejects or reports an ambiguous failure after acceptance.
  • Redrive retained rows from the Worker scheduled handler.

Why

A final response could be lost when D1 insert succeeded but Queue dispatch failed: the previous path deleted the only durable delivery record.

Verification

  • Commands: just test-file apps/api/tests/channel-final-delivery-scheduling.test.ts (15 pass); just tc-package @mosoo/api.
  • Manual steps: injected both an ambiguous Queue result (message accepted, then send() throws) and a rejected Queue send. The real final-delivery ledger, Worker scheduled handler, queue consumer, and in-memory D1 path retained the job, redrove it, delivered it, and ACKed it.
  • Not run: just check was not run; no real Cloudflare production account or remote Queue/D1 was used.

Impact

  • User/API/contract changes: None.
  • Generated files / GraphQL / DB / lockfile: None.
  • Env or config changes: None.
  • Risk and rollback: The scheduled redrive scans a bounded set of retained jobs. Revert this PR to stop new redrives; retained ledger rows remain available for controlled recovery.

Review

  • Closest review areas: channel final-delivery ledger, Worker scheduled handling, queue idempotency.
  • Known trade-offs: Cloudflare platform behavior was not tested against a real account. The local verification uses the real D1/Worker/service chain with Queue behavior injected only at the Cloudflare binding boundary.

@AsperforMias
AsperforMias marked this pull request as draft July 14, 2026 11:00
@Yevanchen
Yevanchen force-pushed the fix/channel-final-delivery-outbox branch 7 times, most recently from 5faacd0 to 8abf177 Compare July 21, 2026 16:05
@Yevanchen
Yevanchen force-pushed the fix/channel-final-delivery-outbox branch 2 times, most recently from 72454d2 to 383aa75 Compare July 25, 2026 16:06
@Yevanchen
Yevanchen force-pushed the fix/channel-final-delivery-outbox branch 6 times, most recently from a8e1ef5 to a8736bc Compare July 31, 2026 16:07

@Yevanchen Yevanchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the durable outbox/redrive flow and did not find a code-level blocker in this pass. This still should not merge now: Channels is deliberately unavailable as an end-to-end product surface (no reachable setup UI or provider live-account smoke), and #303 is deferred rather than fixed.

Keep this draft; when Channels is revived, rebase onto current main and rerun the current repository plus live-boundary verification.

@Yevanchen
Yevanchen force-pushed the fix/channel-final-delivery-outbox branch 3 times, most recently from ef1cba1 to 33b71a4 Compare August 20, 2026 16:11
@Yevanchen
Yevanchen force-pushed the fix/channel-final-delivery-outbox branch from 33b71a4 to 51a57b0 Compare August 21, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): retain channel final-delivery jobs after ambiguous Queue sends

2 participants