Repository navigation
Conversation
Login uses a fixed local redirect port (52700 for Google, 52701 for Azure). If a second `p0 login`, or a command that starts a login, runs while another is waiting for browser approval, binding that port failed with a raw `listen EADDRINUSE` error. `withRedirectServer` now detects `EADDRINUSE` and fails with a short message naming the port and telling the user to finish or cancel the other login and rerun. The message is thrown as a plain string so no stack trace prints. Other `listen` errors are passed through unchanged, and the ports and the login flow are the same when the port is free. The listen error handler also no longer rejects the redirect promise, which nothing awaits at that point and which would have surfaced as an unhandled rejection that hid the new message.
Contributor
Author
|
@coderabbitai review |
Action performed
|
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.
Problem
Login uses a fixed local redirect port (52700 for Google, 52701 for Azure) because the OAuth clients only accept exactly registered redirect URIs. If a second
p0 login, or any command that starts a login, runs while another login is waiting for browser approval, the second process fails with a rawlisten EADDRINUSE: address already in useerror that doesn't tell the user what to do.Status: N/A
Change
withRedirectServernow checks forEADDRINUSEwhen the redirect server starts listening. In that case it fails with:withRedirectServer.listenerror is rejected with the original error object, as before.redirectReject.redirectPromiseis never awaited whenlistenfails, so rejecting it produced an unhandled rejection. The global handler would printUnhandled Rejection: ...and exit before the new message appeared.Check off any of the following areas of code that are modified:
Type of Change
Validation
src/common/auth/__tests__/server.test.tsholds a port open with anhttpserver and assertswithRedirectServerrejects with the exact message and never callsbeginAuth. Results from the last review pass (no findings):yarn prettier --check .: pass for all source files (only the untracked.ship-tickethandoff files are flagged)yarn eslint --max-warnings 0 .: passyarn tsc: passNODE_ENV=unit yarn vitest run: 349 passed, 8 failed. The 8 failures are insrc/commands/__tests__/ssh.test.tsand also fail on the base commit (a local tool-installation check). The new test passes.src/common/auth/server.ts, used by Google and Azure login.Rollout / rollback
N/A
Tracking (optional)
https://linear.app/p0-security/issue/CUS-221/p0-cli-fails-with-eaddrinuse-on-port-52700-when-two-commands-run-at
Implementation (optional)
The message is written inline at its single call site rather than as a helper or shared constant.
Follow-up Work (optional)
Review raised nothing that went unfixed. Out of scope here:
listenstay registered whenlistenfails. The process exits right after, so this has no effect today.ssh.test.tstests and 6 obsolete snapshots predate this change.