Repository navigation
fix(desktop): match WSAEADDRINUSE on Windows and repair the Go test build - #1909
Open
JasonBuildAI wants to merge 1 commit into
Open
JasonBuildAI wants to merge 1 commit into
JasonBuildAI wants to merge 1 commit into
Conversation
…uild listenProbe matched a busy port with syscall.EADDRINUSE, whose Windows value (0x20000002) never equals the Winsock errno net returns (10048). A busy preferred port therefore aborted firstFreePort instead of skipping ahead, and the desktop stopped on its saved port instead of trying 8089+. Detect the platform errno via a build-tagged addrInUse helper (x/sys/windows WSAEADDRINUSE on Windows, EADDRINUSE elsewhere). filedrop_test.go also declared err twice, so the desktop test package did not compile and hid the failure above; drop the duplicate and add a live-listener regression test for the skip path. Fixes TencentCloud#1905.
JasonBuildAI
force-pushed
the
fix/agent-c1f7-work
branch
from
October 15, 2026 17:38
dbc9a0b to
ffdd5ff
Compare
This branch has not been deployed
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
desktop/src's Go test package does not compile ondevelop(filedrop_test.go:91redeclareserr), and that compile error hides a real Windows-only defect from #1874:listenProbematches busy ports witherrors.Is(err, syscall.EADDRINUSE), but Windows reports a busy socket as Winsock errno 10048 (WSAEADDRINUSE) while Go'ssyscall.EADDRINUSEon Windows is the synthetic value0x20000002, so the check can never be true. A busy preferred port (default 8088) therefore abortsfirstFreePortinstead of skipping ahead, and the desktop stops with a raw Winsock message instead of starting on 8089+ - the exact "second Octop instance" scenario #1874 set out to fix. Fixes #1905.Target branch
develop(feature / fix - default)main(release/*orhotfix/*only)Type of change
How it is fixed
desktop/src/filedrop_test.go: drop the duplicatevar err errorinTestDropServerServesOnlyPublishedFiles, sogo test ./.../go vet ./...build again (go build ./...was never affected because it ignores_test.gofiles).addrInUse(err error) boolhelper behind build tags:process_windows.gouseserrors.Is(err, windows.WSAEADDRINUSE)(golang.org/x/sys/windows, already a direct dependency),process_unix.gokeepssyscall.EADDRINUSE.listenProbecalls the helper.cannotBindError/noFreePortErrorhandling inboot()is unchanged (TestChooseFreePortStopsWhenHostCannotBindstill passes).TestChooseFreePortSkipsALiveListenerbinds a real listener and assertschooseFreePortskips it - the user-visible path that regressed.Test plan
Windows 11 x64, go1.25.9, worktree at
544ea757(develop).develop:Errno probe on the same host (scratch program, not committed):
process.go+ the new tests (both fail, so the new test is a real regression guard):Python side (this change touches no Python code;
makeis unavailable on Windows, so the Makefile targets were run as their underlying commands):uv run ruff check src tests->All checks passed!uv run ruff format --check src tests->1177 files already formatteduv run mypy src/octop->Success: no issues found in 569 source filesuv run pytest -n auto -m "not live" -q->28 failed, 4409 passed, 202 skippedin 26:4227 failed, 67 passed, 1 skipped; the extratests/unit/connectors/test_agently_auth.py::test_login_error_and_refresh_never_expose_cli_outputfailure in the full run passes standalone and under-n autoon the pristine tree (test-ordering/resource flake). The 27 environment failures are pre-existing (tests/unit/db/*legacy-migration fixtures andtests/unit/test_vendor_wheels_argv.py, the latter tracked by test(desktop): apply posix_only to the vendor-wheels argv cases #1812).Checklist
makeis unavailable in this Windows clone, so the Makefile targets were run as their underlying commands).ruff check/ruff format --check/mypypass; thepytest -m "not live"run reports 28 failures, all pre-existing on this host (27 reproduced with this change stashed, plus one xdist flake), and this PR touches no Python file.CHANGELOG.mdNote for reviewers, not part of this PR:
ci.ymlhas no Go test job andoctop-desktop.ymlonly packages the app, which is why a non-compiling test package sat unnoticed since #1874. Adding ago vet ./...+go test ./...job fordesktop/srcwould catch this class of regression; happy to follow up separately if wanted.AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.