diff --git a/pipeline_tree.go b/pipeline_tree.go index a7bba0d..1ec8d48 100644 --- a/pipeline_tree.go +++ b/pipeline_tree.go @@ -148,11 +148,13 @@ func (*treePipeline) handlePipelineErr(ctx context.Context, echs ...<-chan error eg.Go(func() error { for { select { - case err := <-echs[i]: + case err, ok := <-echs[i]: + if !ok { + return nil + } if err != nil { return err } - return nil case <-ectx.Done(): return ectx.Err() } diff --git a/pipeline_tree_spreader.go b/pipeline_tree_spreader.go index a207060..279aa29 100644 --- a/pipeline_tree_spreader.go +++ b/pipeline_tree_spreader.go @@ -52,7 +52,9 @@ func (ds *defaultSpreaderPipeline) spread(ctx context.Context, w io.Writer, root } wg.Wait() - errc <- bw.Flush() + if err := bw.Flush(); err != nil { + errc <- err + } }() return errc