From 6ca4c3eba6361e22d712d1b279b1c55c567b81b5 Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Mon, 13 Apr 2026 16:44:56 +0800 Subject: [PATCH] fix: don't close signal channel in walker goroutines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #37 --- dag.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/dag.go b/dag.go index c75918b..67857cc 100644 --- a/dag.go +++ b/dag.go @@ -601,7 +601,6 @@ func (d *DAG) AncestorsWalker(id string) (chan string, chan bool, error) { d.walkAncestors(vHash, ids, signal) d.muDAG.RUnlock() close(ids) - close(signal) }() return ids, signal, nil } @@ -855,7 +854,6 @@ func (d *DAG) DescendantsWalker(id string) (chan string, chan bool, error) { d.walkDescendants(vHash, ids, signal) d.muDAG.RUnlock() close(ids) - close(signal) }() return ids, signal, nil }