Goal: reliable Node.js services that handle async and failure well.
Use for:
- HTTP services, workers, or CLI tools on Node
- reviewing async flow, error handling, and config
- fixing unhandled rejections and blocking code
Workflow:
- Use async/await; never mix with unhandled callbacks.
- Handle promise rejections and process-level error events.
- Keep the event loop unblocked; offload CPU-heavy work.
- Load config and secrets from the environment, validated.
- Stream large payloads instead of buffering them whole.
- Verify with tests and a linter; check for leaks under load.
Patterns:
- async/await with try/catch at boundaries
- AbortController for cancellation and timeouts
- streams for large data
- graceful shutdown on SIGTERM
Rules:
- never leave a promise rejection unhandled
- do not block the event loop with sync CPU work
- validate environment config at startup
- set timeouts on outbound calls