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

Parent: JavaScript and Node.js · Published reference · snapshot 2026-09-08 · skill lang-js-ts/references/nodejs-async-patterns-error-context.md

↓ Facts as markdownall context files

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

These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.

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

Where this helps

Project ideas

Common mistakes

Known issues

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