fix: don't close signal channel in walker goroutines to prevent panic#45
Merged
Merged
Conversation
AncestorsWalker and DescendantsWalker close both 'ids' and 'signal' channels when the walk completes. If the consumer stops at the last vertex and then sends on the signal channel, it panics with 'send on closed channel'. The signal channel is owned by the consumer (they send on it to stop the walk). The goroutine should not close it — only close 'ids' to signal completion to the consumer. Fixes heimdalr#37
sebogh
approved these changes
Apr 14, 2026
Collaborator
|
Thanks @Yanhu007 |
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 #37
Problem
AncestorsWalkerandDescendantsWalkerclose bothidsandsignalchannels when the walk completes. If the consumer stops at the last vertex and then sends on the signal channel, it panics:Root Cause
The goroutine closes
signalafter the walk finishes, but the consumer may try to send on it after receiving the last vertex:Fix
Remove
close(signal)from both walker goroutines. The signal channel is a send-only channel from the consumer's perspective — the goroutine should not close it. The consumer signals the goroutine to stop; the goroutine signals the consumer by closingids.All existing tests pass.