Repository navigation
Conversation
recv and send on a socket that had been shut down fell through to unexpectedWSAError, which cast the code to Win32Error. WSA codes aren't in that enum, so safe builds panicked. POSIX reports the same race as EOF and EPIPE, and any other unmapped WSA code took the same path. Assisted-by: Claude Opus 5.5
endel
force-pushed
the
iocp-shutdown-errors
branch
from
October 30, 2026 20:27
3acee7f to
65bec85
Compare
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.
On the IOCP backend,
recvandsendon a socket that has been shut down fail withWSAESHUTDOWN, which neither maps. It falls through tounexpectedWSAError, which casts the code toWin32Error. WSA codes aren't in that enum, so a safe build panics withinvalid enum value. Any other unmapped WSA code takes the same path.We hit this in quic-zig, when a write raced a connection being closed. POSIX reports that race as EPIPE, and a read after shutdown as EOF.
Fix
recvreportsWSAESHUTDOWNaserror.EOF, andsendaserror.ConnectionResetByPeer, both when the call fails at once and when it completes with that status.unexpectedWSAErrorlogs the code and returnserror.Unexpectedwithout the cast.Test
"iocp: recv and send on a socket that was shut down" shuts a connected socket down, queues a
recvand asend, and checks both results. Without the fix it panics.processtests can't run in that container, as it lacks their helper binary.zig build test, 59 passedzig build -Demit-example -Demit-bench, andzig buildfor every target in the CI matrixCI on
mainfails until #250 moves the workflow to Zig 0.17, so this PR's checks will fail the same way until then.🤖 Generated with Claude Code