Fiber cancellation via Cancel and OnCancelled
Platform spec ADR
Fiber cancellation via Cancel and OnCancelled
Spec standingStandard
- Concurrency package - Contracts and edge cases Send, Receive, Join, Cancel, and Hub normative contracts.
- Concurrency package - Decisions record (legacy index) Migration index pointing to per-decision ADR files under adr/—normative text lives in ADRs, not this page.
- Concurrency package - Design model Package layout, module map, and thin-wrapper rule for Fiber and Channel structs.
- Concurrency package - Examples Illustrative spawn, Channel, and Hub usage (informative).
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Context
Section titled “Context”Fibers need cooperative cancellation without panics on join or parked channel ops.
Decision
Section titled “Decision”| Rule | Detail |
|---|---|
| Signal | Fiber.Cancel() sets runtime cancellation flag |
| Event | Each `Fiber<T>` declares event OnCancelled(); runtime raises on child before unblocking parked ops |
| Join | Join → `Result<T, FiberError::Cancelled>` after cancellation observed |
| Channels | Parked Send / Receive → ChannelError::Cancelled |
| Ordering | OnCancelled runs before Join / channel errors; handlers must not block on Join of self |
Consequences
Section titled “Consequences”Unhandled panic in OnCancelled aborts process in v1 (same as other unhandled event paths).
Verification anchors
Section titled “Verification anchors”Corelib + runtime concurrency tests; cancel/join fixtures.