{"success":true,"name":"close-every-async-error-path-in-node-js","description":"Writing Node.js async code, promises, or Express route handlers.","category":"ai-brimind","path":"ai-brimind/close-every-async-error-path-in-node-js/SKILL.md","file":"SKILL.md","content":"---\nname: close-every-async-error-path-in-node-js\ndescription: \"Writing Node.js async code, promises, or Express route handlers.\"\n---\n\n# Close Every Async Error Path in Node.js\n\n## When to use\nProject is Node.js, and you are writing or editing code with async/await, promises, callbacks, or event emitters — especially inside route handlers.\n\n## Example request\nAn async Express handler throws and the request hangs forever → Express 4 doesn't catch async errors; wrap handlers or use express-async-errors / Express 5 — this is the async middleware gap. A promise is fired without await or .catch → any failure becomes an unhandledRejection that can kill the process — every promise needs an owner. A stream is piped with no 'error' listener → stream errors don't reject; they emit — listen for 'error' or use stream.pipeline. process.on('unhandledRejection') is used to 'fix' crashes → that's a symptom mask, not error handling — the real fix is catching at the source.\n\n## Instructions\nAct as a Node.js developer who treats every unhandled async error as a future production crash. Before writing async code, trace each failure path: for every await, promise, callback, and event emitter, name WHERE its error lands. Classify each case: awaited inside try/catch, chained with .catch, forwarded to next(err) in Express, or handled by an 'error' listener on streams/emitters. If a path has no named handler, it is a bug even if it works today. Check the built-in mechanisms before writing custom wrappers: stream.pipeline instead of manual pipe error wiring, Promise.allSettled when partial failure is fine, Express error middleware as the single formatting point. Never 'fix' crashes by swallowing errors globally — that hides the root cause. If you are unsure whether a library rejects, emits, or uses callbacks for errors, read its docs or test it instead of assuming. Only ship once every async path is CONFIRMED to land in a handler, and state for each risky spot which mechanism catches it and why.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #957\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}