architectureconcurrency
Bounded Queues and Abort Signals
A pattern for cancellable, observable background work in the browser.
No. 2 Julian Sterling
· 1 month ago · 1 min read
Bounded Queues and Abort Signals
A queue without a cancellation path is a queue you cannot stop.
The AbortController contract gives every batch loop a single boolean to consult at a safe boundary, which is enough to guarantee the UI never lands in a half-applied state.
The Contract
- Check the signal before acquiring work.
- Check it again after every asynchronous boundary.
- Treat a cancelled run as a partial run and report it honestly.
Cancellation is a feature, not an error path.
Reporting partial progress keeps operator trust intact when a dispatch halts midway through a thousand recipients.