fix(windows): preserve data-path backpressure - #3704
Open
mozharovsky wants to merge 1 commit into
Open
Conversation
mozharovsky
force-pushed
the
fix/windows-data-path-backpressure
branch
from
August 16, 2026 02:28
a080762 to
92c33bd
Compare
Mirror Posix.syscall for Winsock data calls and cover both wrapper variants plus full stream delivery under forced backpressure.
mozharovsky
force-pushed
the
fix/windows-data-path-backpressure
branch
from
August 17, 2026 17:54
92c33bd to
b320d90
Compare
|
Independent verification from the Hummingbird side, on a clean windows-2022 GitHub runner (Swift 6.3.3). Applied this branch (
Both were failing with "stream ended at an unexpected time" before this change. With it, the full streamed-body set is green ( |
This was referenced Aug 21, 2026
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.
Treat
WSAEWOULDBLOCKas nonblocking backpressure across the existing Windows data path.Motivation:
Nonblocking Winsock operations report backpressure by returning
SOCKET_ERRORand settingWSAEWOULDBLOCK. The existingacceptandconnectwrappers already classify this condition as nonfatal, and #3699 does the same for its newsendmmsgimplementation. The existingrecv,send,writev,recvmsg, andsendmsgwrappers instead throwIOErrorbefore the channel can wait for readiness.In a downstream production workload, this surfaced as Windows error 10035 and an
uncleanShutdownabout two seconds into bulk TLS uploads, while low-volume traffic remained unaffected. The same mapping has been shipping in a downstream fork and eliminates the failure.Fixes #3697.
Fixes #3702.
Modifications:
winsockSyscall(where:_:)overloads that mirrorPosix.syscalland use the samewhere function: String = #functionconvention.WSAGetLastError()immediately when the call returnsSOCKET_ERROR.DWORDout-parameter. It reads the count only after success and ignores any value a failed call leaves in that slot.recvandsendthrough the single-closure overload, and routedrecvmsg,sendmsg, andwritevthrough the transferred-count overload without changing any public API.acceptandconnectunchanged. Unifying their nonblocking handling is a separate NFC follow-up.Neither overload has an
EINTRretry loop.WSAEINTRonly arises from the legacyWSACancelBlockingCall, which does not apply to the nonblocking sockets used by these data paths.Using
#functiondeliberately changes the fiveIOErrorreason strings from bare implementation names such as"recv"and"WSASend"to the full caller signatures such as"recv(socket:buffer:length:)"and"writev(socket:iovecs:)". The error codes and public API are unchanged.This complements #3699 and #3700. I am happy to rebase over them when they land and fold the
sendmmsgcall into the shared wrapper as a follow-up.Result:
The stream regression test fails on unpatched Windows with
WSAEWOULDBLOCKsurfaced asA non-blocking socket operation could not be completed immediately.Both wrapper overloads and the unchanged stream regression pass with this change on Windows x64 using the current development toolchain:The full macOS suite passes with 2,460 XCTest tests and 276 Swift Testing tests. The Swift 6.2 formatter check, API breakage check, unacceptable-language check, license-header check, and broken-symlink check all pass locally.