Fix infinite broken accept loop for Windows named pipe listeners#86
Merged
kotauskas merged 1 commit intokotauskas:mainfrom Dec 9, 2025
Merged
Fix infinite broken accept loop for Windows named pipe listeners#86kotauskas merged 1 commit intokotauskas:mainfrom
accept loop for Windows named pipe listeners#86kotauskas merged 1 commit intokotauskas:mainfrom
Conversation
…ent connection disconnects very early in the pipe lifecycle
Owner
|
Here's my theory of what's going on here:
I think the correct reaction to I'll merge this now and implement the above solution when I have time. Thank you for diagnosing this! |
kotauskas
added a commit
that referenced
this pull request
Jan 25, 2026
Owner
|
aa486ab applies the permanent fix I've described above. |
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.
While debugging some other issue in my own code, I found that some buggy IPC client behaviour can potentially break the named pipe listener on Windows. It's been hard to reproduce consistently, but it seems like the following rough sequence of events can trigger it:
tokio)accept()on listener, which returns win32 error232(ERROR_NO_DATA/The pipe is being closed) infinitely. No more connections are accepted.From reading the documentation by Microsoft (https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-connectnamedpipe), it seems like
ERROR_NO_DATAis returned when "a previous client has closed its pipe handle but the server has not disconnected."Then, from the first paragraph in the "Remarks" section:
From looking at the
acceptcode in this crate, it seems like a new named pipe instance is created only if the call toConnectNamedPipedoes not fail (which is does in this case). I modified the function to now specifically check for theERROR_NO_DATAerror, and then recreate the instance if it finds it. The error is still returned, but only once now, which I think probably makes more sense.I'm no win32 expert, so I'm not 100% sure this solution is the right one, but it seems to have fixed the behaviour in my own code at least.