fix(llm): use Windows WSA errnos instead of string matching#953
Merged
cpcloud merged 3 commits intomicasa-dev:mainfrom Apr 18, 2026
Merged
fix(llm): use Windows WSA errnos instead of string matching#953cpcloud merged 3 commits intomicasa-dev:mainfrom
cpcloud merged 3 commits intomicasa-dev:mainfrom
Conversation
The previous fix restored substring matching for the Windows CI failure, but the real cause is more fundamental: syscall.ECONNREFUSED on Windows is an APPLICATION_ERROR-prefixed invented constant (1<<29 + iota), NOT the actual WSA error code (10061) that net/http returns. errors.Is can never match it on Windows because the values are different integers. Split the errno sentinel list across build-tagged files: POSIX uses the standard syscall constants; Windows uses windows.WSAECONNREFUSED, WSAENETUNREACH, and WSAEHOSTUNREACH from golang.org/x/sys/windows (already a direct dep, exposed as syscall.Errno). isNetworkError becomes a simple loop that calls errors.Is on the right values for the current platform. Zero string matching on either platform.
…rrno gotcha
Codify the lesson from the connectex CI failure. syscall.ECONNREFUSED
on Windows is APPLICATION_ERROR + iota, NOT the WSA error code that
net/http surfaces, so errors.Is against the standard syscall.Errno
sentinels always returns false. The fix is build-tagged sentinel lists
that use golang.org/x/sys/windows.WSA* on Windows; see
internal/llm/network_errors_{windows,other}.go for the pattern.
The previous commit gated isNetworkError on platform-specific connectionErrnos but left the tests wrapping syscall.ECONNREFUSED directly. On Windows that's an APPLICATION_ERROR-prefixed invented constant, not the WSA value the production check uses, so the tests failed on windows-11-arm CI. Reach into connectionErrnos[0] for the representative connection-refused sentinel; it resolves to syscall.ECONNREFUSED on POSIX and windows.WSAECONNREFUSED on Windows.
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
syscall.ECONNREFUSEDon Windows is defined as `APPLICATION_ERROR | iota` (an invented value, not the real WSA error code), so `errors.Is(err, syscall.ECONNREFUSED)` always returns false on Windows for real network errors. Same for `ENETUNREACH` and `EHOSTUNREACH`.