fix: detect port-in-use before starting (#1234)#1313
Closed
echopi wants to merge 1 commit intoavwo:masterfrom
Closed
fix: detect port-in-use before starting (#1234)#1313echopi wants to merge 1 commit intoavwo:masterfrom
echopi wants to merge 1 commit intoavwo:masterfrom
Conversation
c7878f5 to
f587831
Compare
Add a pre-flight port availability check in cluster/daemon mode to catch port conflicts early, before whistle silently starts on a partially occupied port. - checkPortAvailable() probes 0.0.0.0 to detect IPv4 port conflicts even when the real server would bind to IPv6 - Errors propagate naturally via throw (no process.exit in library code) - Non-cluster mode preserves synchronous return (programmatic API compat) - Skip check when a custom server is provided (already bound) - Existing EADDRINUSE fallback in bin/whistle.js preserved Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f587831 to
3c6c03f
Compare
echopi
added a commit
to echopi/whistle
that referenced
this pull request
Apr 6, 2026
Add a port availability pre-check before starting the whistle server. When the port is already in use, output a friendly error message to stderr and exit, instead of crashing with an uncaught exception. Compared to the previous attempt (PR avwo#1313), this fix: - Works for all startup modes, not just cluster mode - Uses console.error + process.exit instead of throw in async callback - Does not include unrelated changes (cluster mode, config loading, etc.) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
Contributor
Author
|
Superseded by #1316 — fix moved to lib/index.js with proper error handling, no TOCTOU, no return value regression. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1234 —
w2 startsilently starts even when the default port (8899) is already occupied, causing confusing behavior.Changes:
checkPortAvailable()pre-flight check inindex.jsbefore starting whistlebin/whistle.jspreserved as fallbackTest plan
w2 start— should see error and exitw2 start -p 9999with 8899 occupied — should start normally on 9999w2 startwith port free — should start normally (no behavior change)🤖 Generated with Claude Code