Skip to content

fix: prevent unbounded wait during pipe listener close - #364

Closed
Kiell Tampubolon (glatinone) wants to merge 2 commits into
microsoft:mainfrom
glatinone:fix/listener-close-pending-connect
Closed

fix: prevent unbounded wait during pipe listener close#364
Kiell Tampubolon (glatinone) wants to merge 2 commits into
microsoft:mainfrom
glatinone:fix/listener-close-pending-connect

Conversation

@glatinone

Copy link
Copy Markdown

Description

Addresses a potential unbounded shutdown hang in win32PipeListener.Close().

Technical Changes

  • Replaced the unconditional blocking read err = <-ch inside the case <-l.closeCh: block with a bounded select statement utilizing a 100-millisecond timeout guard via time.After.
  • Converted the unbuffered error communication channel to a buffered channel (make(chan error, 1)) to guarantee the background connection goroutine can complete its write and exit cleanly after a timeout event, preventing runtime goroutine leaks.
  • Integrated a targeted integration test in pipe_test.go to verify bounded execution windows during concurrent listener termination.

Verification

Validated successfully on a remote windows-latest cloud runner.

…leak

makeConnectedServerPipe previously blocked indefinitely on <-ch after
Close() aborted a pending ConnectNamedPipe, with no bound on how long
that wait could take. Add a bounded 100ms drain so Close() returns
promptly even if the underlying I/O completion is delayed.

The connect goroutine's result channel was unbuffered, so abandoning
the wait after the timeout would leak that goroutine forever on its
blocking send. Buffer the channel (capacity 1) so the goroutine can
always deliver its result and exit cleanly regardless of whether
anyone is still listening.

Adds TestListenerCloseDuringPendingConnectReturnsPromptly and a
windows-latest GitHub Actions workflow to verify it on a real
Windows runner.

Signed-off-by: glatinone <93207632+glatinone@users.noreply.github.com>
golangci-lint's errorlint check flagged the direct != comparison
against ErrPipeListenerClosed in the new test. Use errors.Is to
match repository convention and satisfy the zero-tolerance lint
gate in .golangci.yml.

Signed-off-by: glatinone <93207632+glatinone@users.noreply.github.com>
@glatinone
Kiell Tampubolon (glatinone) requested a review from a team as a code owner July 10, 2026 08:14
@glatinone

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@glatinone

Copy link
Copy Markdown
Author

Closing this PR to avoid adding unnecessary review overhead for maintainers. Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant