From 26c9acb5b13c6f7fe39c5612d4c691184375937f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 21 Feb 2019 17:58:08 +0100 Subject: [PATCH] avoid ctx.Done() goroutine leak in Selector.run As spotted in #162 by a contributor, if the context is done before the Selector.run caller has received from the channel, the spawned goroutine may leak if blocked on a send. --- sel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sel.go b/sel.go index e512c01..bbfc720 100644 --- a/sel.go +++ b/sel.go @@ -80,7 +80,7 @@ func (s *Selector) Do(ctxt context.Context, h cdp.Executor) error { // are invalidated prior to finishing the selector's by, wait, check, and after // funcs. func (s *Selector) run(ctxt context.Context, h *TargetHandler) chan error { - ch := make(chan error) + ch := make(chan error, 1) go func() { defer close(ch)