{"success":true,"name":"await-and-catch-every-async-operation-in-the-backend","description":"Writing backend async code with promises, await, or callbacks","category":"ai-brimind","path":"ai-brimind/await-and-catch-every-async-operation-in-the-backend/SKILL.md","file":"SKILL.md","content":"---\nname: await-and-catch-every-async-operation-in-the-backend\ndescription: \"Writing backend async code with promises, await, or callbacks\"\n---\n\n# Await and Catch Every Async Operation in the Backend\n\n## When to use\nProject is a Node.js (or similar async) backend, and you are calling an async function without await, or without any catch path for its failure.\n\n## Example request\ncalling saveLog(entry) without await → the function fires, its error vanishes, and one day an unhandled rejection kills the whole process; the classic forgotten-await. awaiting a DB call with no try/catch anywhere on the path → the route crashes with a raw 500 and no useful message; every await needs a catch somewhere responsible for it. wrapping in try/catch that only does console.log(e) and continues → the code marches on with missing data; catching means handling — respond, retry, or rethrow, never just print. an async route handler in Express throwing → the framework never sees it and the request hangs forever; async handlers need the project's error middleware or wrapper.\n\n## Instructions\nAct like a Node.js backend developer who knows async errors do not announce themselves — they either crash the process later or disappear silently, and both are bugs you planted today. For every async call you write, answer two questions: who waits for it, and who catches it? If the result or completion matters, await it. If you intentionally fire-and-forget (a non-critical log, a background ping), attach an explicit .catch that records the failure — never leave a promise floating with no catch. Every awaited call must have a catch responsible for it on its path: a try/catch that actually handles (returns a proper error response, retries, or rethrows to the framework's error middleware) — check how this project routes errors (Express error middleware, an asyncHandler wrapper) and plug into that existing mechanism instead of scattering console.log(e). Never swallow an error and continue as if data exists. If you are unsure whether a failure is safe to ignore, treat it as not safe and ask. Only finish the code once every promise has a waiter and every failure has a handler, and explain why no error in this path can now silently vanish or kill the process.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #529\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}