Skip to content

Comments

fix: Server error handler calls process.exit() bypassing cleanup#206

Draft
dcramer wants to merge 2 commits intomainfrom
warden-sweep/1984f16e/find-warden-bugs-19c99a7a
Draft

fix: Server error handler calls process.exit() bypassing cleanup#206
dcramer wants to merge 2 commits intomainfrom
warden-sweep/1984f16e/find-warden-bugs-19c99a7a

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Feb 22, 2026

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).

This PR was auto-generated by a Warden Sweep (run 1984f16e).
The finding has been validated through automated deep tracing,
but human confirmation is requested as this is batch work.

dcramer and others added 2 commits February 21, 2026 21:47
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>
@dcramer dcramer added the warden Automated fix from Warden Sweep label Feb 22, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}`));
}
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

warden Automated fix from Warden Sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant