You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
workflows: persistence exception mid-batch drops later envelopes from in-memory retry queue #108
Verified by read-only audit (seal/gpt-5.6-sol subagent, verdict: CONFIRMED).
flush() snapshots the entire batch and removes every envelope from pending before attempting delivery (extensions/workflows/result-delivery.ts:65-69). persistState() mutates details.delivery then calls options.persist(details) with no exception handling (result-delivery.ts:43-58).
Transport exception path (result-delivery.ts:72-83): each envelope is re-enqueued immediately before persistState(). If persistence throws on envelope N, envelopes 1..N are in pending; envelopes after N stay removed and the loop terminates.
Unacknowledged receipt path (result-delivery.ts:115-120): enqueues then calls uncaught persistState() — a throw again aborts all later envelopes. (The delivered-receipt path at result-delivery.ts:91-113 has its own per-envelope catch.)
finally only clears flushing (result-delivery.ts:122-124); it does not restore the unprocessed batch.
Callers do not recover: options.persist is persistWorkflowJson with no wrapper (index.ts:772-798); durable pending runs are restored only at session_start (index.ts:955-993); parentSettled() is fire-and-forget (index.ts:996-998); completion calls releaseInline()/defer() once (index.ts:2081-2082).
Impact
Later envelopes in the batch are lost from the in-process retry queue. Durable "pending" records (written at result-delivery.ts:145-154 before enqueue) usually allow restart-time restoration, but no same-process mechanism reloads them — delivery stalls until restart.
Test coverage gap
result-delivery.test.ts covers transport failure with successful persistence, partial receipts, restoration, and a single delivered-receipt persistence failure — but no multi-envelope test where persistence throws during transport-failure or unacknowledged-receipt processing.
Suggested fix
Isolate persistence failures per envelope and keep every unprocessed envelope retained in pending before any persistence operation can abort iteration (e.g. a finally that re-enqueues all unprocessed envelopes).
Activity