Repository navigation
fix: recognize occupied ports returning HTTP errors - #2871
Open
curforever wants to merge 1 commit into
Open
curforever wants to merge 1 commit into
curforever wants to merge 1 commit into
Conversation
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
When a process listening on the requested Metro port returns HTTP 400/404/500 for
/status, the shared fetch helper throwsCLIError.isPackagerRunningcurrently converts that response tonot_running, sofindDevServerPortskips the occupied-port flow and can try to start Metro on the same port.Recognize the existing HTTP
CLIErrorasunrecognized. Connection failures retain their existing behavior, and the public return type is unchanged. Add regression coverage with actual local HTTP servers and the port-selection caller.Refs #2852; this addresses the HTTP-error classification case, not all errors discussed in that issue.
Test Plan
yarn jest --selectProjects unit --runInBand packages/cli-tools/src/__tests__/isPackagerRunning.test.ts.yarn lint: 0 errors, 2 existing warnings. The workspace path contains#, so lint ran through a temporary ASCII alias with equivalent workspace junction targets. All targets and the alias were restored; no rules disabled.copyFilescase was independently reproduced with unchanged source on the fourth isolated run. The full Windows suite is not green.file:dependencies/resolutions to the local CLI build. On Node 22.13.0, verified CLIconfig, identical installed detection-module bytes, and 6 real local-HTTP scenarios with the actual built tools and injected prompt answers: error responses use another port when accepted and do not start Metro when declined; normal responses and closed ports retain their behavior. Metro responses were synthetic protocol responses; no real Metro/native Android/iOS build or full Linux/macOS e2e matrix was run locally.Investigation, implementation and tests were AI-assisted. The validation steps above were executed locally; no manual maintainer review is claimed.
Checklist