Node.js Async Control-Flow, Errors & Context Propagation

Parent: JavaScript and Node.js · researched 2026-06-02T18:03:41.863Z· 8 sources · 7 concepts · skill nodejs-async-patterns-error-context

This reference is the layer above basic promises. Once you can await, three problems

Overview

1. Cancellation — `AbortController` / `AbortSignal`

2. Composing signals — `AbortSignal.timeout()` and `AbortSignal.any()`

3. Structured errors — `Error.cause`, `AggregateError`, custom classes

4. The `error.code` convention — match on code, never message

5. Process-level failure — rejections, exceptions, and exit semantics

6. Promise concurrency — `all` vs `allSettled` vs `any` vs `race`

7. Context propagation — `AsyncLocalStorage` (+ `async_hooks`/`AsyncResource`)

Practical patterns

Anti-patterns

Troubleshooting

References

Children

Frontier under this node: Cancellation with AbortController / AbortSignal (signal, reason, 'abort', throwIfAborted), Composing signals — AbortSignal.timeout() and AbortSignal.any(), Context propagation — AsyncLocalStorage (+ async_hooks / AsyncResource), Process-level failure — unhandledRejection / uncaughtException / rejectionHandled and exit semantics, Promise concurrency — all vs allSettled vs any vs race + concurrency limiting, Structured errors — Error.cause, AggregateError, custom error classes, The error.code convention — match on code, never message

← the whole tree · 3D view· how to read this page