fix(backend): keep chat alive when default-workflow installation fails
WHY THIS MATTERS buildWorkflowStore() awaited ensureDefaultWorkflows(), which throws on any RPC error, on every chat message - and the chat routes call it OUTSIDE their try/catch blocks. Reproduced live: dropping the RPC (equivalent to deploying code before the migration, or one database hiccup) and sending a single chat message printed UnhandledPromiseRejection and the Node process exited. The entire backend went down for every user, and the next message after a restart killed it again. WHAT IS AN UNHANDLED REJECTION CRASH? Express 4 route handlers are plain functions; if you pass an async function and it throws before you reach your own try block, nothing catches the rejected promise. Since Node 15, an unhandled promise rejection terminates the process by default. That turns "one bad query" into "the whole API is down". (Express 5 forwards async errors to the error middleware; this repo is on Express 4, so every bare async handler carries this risk.) HOW THE FIX WORKS Installing defaults is a convenience, not a prerequisite for chatting, so the call is now best-effort: failures are logged and the chat proceeds with whatever workflows already exist. The user-visible defaults still install on the next successful list/quick-action request, whose asyncRoute wrapper already converts errors into a 500 JSON response instead of a crash. Found by fault-injection review of PR #309. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E4PXCdenNH5Mqhm5Sre9Zs
| Repository | open-legal-products/mike |
|---|---|
| Author | Amal <mamalanand3@gmail.com> |
| Authored | |
| Committed | |
| Parents | 575ba7d2 |
| Stats | 1 file changed , +9 , -1 |
| Part of | Refactor workflows into defaults, add-ons, and quick actions |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-94f2536a.md
from inside the repo you want the change in.