Skip to content

Commit

Permalink
Adding safeguards around Shutdown and AddTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Shaw committed Mar 13, 2017
1 parent 8c9e75e commit ddaa7bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ massif.out

# binaries
/chromedp-gen
/chromedp-proxy
/chromedp-cli
/cmd/chromedp-gen/chromedp-gen
/cmd/chromedp-gen/chromedp-proxy
/cmd/chromedp-gen/chromedp-cli
9 changes: 8 additions & 1 deletion chromedp.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func New(ctxt context.Context, opts ...Option) (*CDP, error) {

go func() {
for t := range c.watch {
if t == nil {
return
}
go c.AddTarget(ctxt, t)
}
}()
Expand Down Expand Up @@ -153,7 +156,11 @@ func (c *CDP) Shutdown(ctxt context.Context, opts ...client.Option) error {
c.RLock()
defer c.RUnlock()

return c.r.Shutdown(ctxt, opts...)
if c.r != nil {
return c.r.Shutdown(ctxt, opts...)
}

return nil
}

// ListTargets returns the target IDs of the managed targets.
Expand Down

0 comments on commit ddaa7bc

Please sign in to comment.