fix: Server error handler calls process.exit() bypassing cleanup#206
fix: Server error handler calls process.exit() bypassing cleanup#206
Conversation
Config mode previously diffed against the default branch (e.g. main), which included all committed branch changes alongside uncommitted ones. Now both config mode and direct skill mode diff against HEAD by default, so `warden` with no args only analyzes uncommitted changes. Add --staged flag that uses `git diff --cached` to analyze only staged changes, supporting pre-commit workflows where you want to review exactly what you're about to commit. Co-Authored-By: Claude <noreply@anthropic.com>
Warden finding find-warden-bugs-19c99a7a Severity: high Co-Authored-By: Warden <noreply@getsentry.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } else { | ||
| reject(new Error(`Server error: ${error.message}`)); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Unhandled promise rejection when server errors during openBrowser
High Severity
The serverError promise is created at line 53 but only gets a rejection handler when Promise.race is called at line 89. When open is true, await openBrowser() at line 69 yields control to the event loop, during which the server's 'error' event (e.g. EADDRINUSE) can fire and reject serverError with no handler attached. In Node.js 15+, this causes an unhandled rejection that crashes the process, bypassing the finally block — the exact cleanup-skipping problem this PR aims to fix.


Replace process.exit(1) in setup-app server error handler with promise-based error propagation, ensuring the finally block, cleanupArtifacts(), and flushSentry() all run on server errors.
The server error handler (e.g. EADDRINUSE) called process.exit(1) directly, terminating the process immediately and bypassing cleanup logic in the finally block and post-command cleanup in main(). The fix uses Promise.race to race the server error against the normal callback flow, letting rejections propagate through the existing catch/finally blocks.
Also deduplicates the URL display logic that was repeated in both the catch and else branches.
Automated fix for Warden finding find-warden-bugs-19c99a7a (high, detected by find-warden-bugs).