test(desktop): deflake Command Code browser login port release - #5479
Open
orangeCatDeveloper wants to merge 1 commit into
Open
orangeCatDeveloper wants to merge 1 commit into
orangeCatDeveloper wants to merge 1 commit into
Conversation
isPortFree previously called occupyPort, retaining an active net.Server in netServers until afterEach rather than probing and releasing immediately. Additionally, tests completing or settling attempts (notably the simultaneous starts test) did not await the winner's loopback port release before entering the next test, leading to EADDRINUSE races where the next test skipped the closing port and unexpectedly bound a higher port number. Generated-by: GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
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
CommandCodeBrowserLoginControllertests intermittently flaked onan occupied port is skipped for the next one in the CLI rangewith46961 !== 46960. Two defects caused the port collision:isPortFreecalledoccupyPort, unintentionally retaining an activenet.ServerinnetServersuntilafterEach.two simultaneous starts) did not await the winner's loopback port release before ending, racing the subsequent test against OS socket teardown.Refs #5395
Verification
Numbers (before -> after):
netServers: 1 -> 0 (isPortFreeimmediately closes upon verifying instead of holding the port untilafterEach).two simultaneous starts: unawaited (racing) -> 100% awaited (assert.equal(await isPortFree(Number(callback.port)), true)).46961 !== 46960) -> 50/50 passed (0 failures).Checks run:
npm run format:check(biome passed)npm run lint(biome passed)npm run typecheckinapps/desktop(passed)npm run check:tui-copy(ok)node scripts/check-renderer-architecture.mjs --base origin/maininapps/desktop(passed)npm run build:mainandnode --test "dist/main/__tests__/commandcode-browser-login.test.js"inapps/desktop(20/20 passed)AI use
Select exactly one:
Tool(s) and scope: GitHub Copilot diagnosed the port race, updated probe behavior and teardown assertions, and verified test suites. Commit includes the
Generated-by: GitHub Copilottrailer.Checklist
Does this PR entail a change in behavior?