Repository navigation
fix: restart the pipeline worker after an idle connection closes - #551
Merged
Mzack9999 merged 1 commit intoOct 30, 2026
Merged
Conversation
3 of 4 tasks
Mzack9999
approved these changes
Oct 30, 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.
Fixes #552
Problem
A
PipelineClientrequest sent after the connection has been idle forMaxIdleConnDuration(10s by default) never returns.When the writer stops on idle,
worker()returns nil and the restart loop ininit()checks whether the queues are empty:chR/chWset.init()only starts a worker whenchR == nil, so the nextDoqueues its request with no worker to send it and blocks on<-w.doneforever.The condition is inverted. There is also a race:
Docalledinit()and then enqueued without holdingchLock, so it could push into a channel whose worker had just decided to stop.Fix
Dostarts a new worker. If work is still queued, keep the channels and let the loop restart the worker.DoandPendingRequestscallinit()and enqueue underchLock, the same lock the stop check holds, so a request can't land in a channel whose worker has exited.Proof
TestPipelineClientReconnectsAfterIdlesends a request, waits past a 50 msMaxIdleConnDuration, then sends another. Before the fix the second request hangs; after it, both succeed.go test -race ./...passes.Downstream, this hangs nuclei
pipeline: truetemplates whenever two sends are more than 10s apart.I used an AI assistant while working on this.