Repository navigation
fix(script): interrupt blocked socket writes on close - #1891
TimotheusG wants to merge 3 commits into
Conversation
|
Reproduced the recovery gap with a per-operation injected OS mode-restoration failure: the write reported an error but the stream still reported connected. Failed nonblocking/blocking transitions now mark the entry unusable and shut down the connection. Callers recheck that state after taking the socket lock, so subsequent or queued I/O cannot use the wrong mode; connected/eof return false/true, and close remains idempotent. The same protection covers the connected-status peek. If the write and restoration both fail, the returned error retains both causes. Two new regression tests cover both mode transitions during write/connected, subsequent read/readln/write rejection, close, and combined failures. All five socket tests passed, including real loopback delivery, timeouts, and concurrent close. The failure is deliberately injected; no naturally occurring platform trigger is claimed. Pushed in f667b6e. The final combined Windows cargo xtask ci passed: 3,685 tests passed, 0 failed, 33 unchanged ignored; formatting, strict Clippy, audits and 32-crate WASM checks passed. The standalone socket PR file is byte-identical to the file validated in the combined audio branch. |
Closing a socket on Windows did not reliably interrupt a blocked
write_all:closereturned, but the writer remained blocked. The existing regression fixture hid this because Windows could accept its entire 64 MiB write before any backpressure occurred.Use a nonblocking write loop with one operation deadline and an explicit close flag, yielding for at most 5 ms while the send buffer is full. Restore blocking mode before returning so subsequent reads retain their behavior. The global table remains unlocked during I/O, and only the socket being written is locked.
The test peer now has bounded receive/send buffers and is filled until it actually reports backpressure.
socket2is a native-only dev dependency for configuring that fixture; the write payload shrinks to 64 KiB. The close test verifies the writer is still pending before closing. A further scenario checks complete 256 KiB transfers and delayed reads on both outgoing and accepted sockets. Related: #1248.The corrected fixture reproduced the close failure before the production fix. All three socket tests then passed in 10 consecutive runs (30 checks). Companion fixes: Unix-only test-helper guard (#1889) and host-independent font tests (#1890).
Validation on Windows x64 (release, LTO disabled and 16 codegen units):
cargo xtask cipassed with all three maintenance fixes applied together: 3,657 tests passed, 32 existing opt-in tests ignored; format, strict Clippy, dependency/layer/asset audits and all 32 wasm crate checks passed.theme::script_font_tests::simplified_chinese_interface_draws_simplified_hanzi_after_another_languagefailure. The identical failure was reproduced in the pre-change UI test binary (run 23 with--test-threads=64). Five complete UI runs with this patch passed, followed by the successful full CI rerun. This separate intermittent issue remains unresolved; no test was disabled to get the passing run.Summary by CodeRabbit