mkenney/go-chrome

Leaking Goroutine

Closed this issue · 6 comments

What version of go-chrome are you using (tagged commit, commit hash, or master)?

84c7e3f

What behavior do you expect? What are you trying to accomplish?

Goroutine ending and possibly returning an error somewhere when chrome closes

What behavior are you experiencing instead?

A goroutine doesn't end after close is being called. Instead it's stuck at the end of socket.listen in github.com/mkenney/go-chrome/tot/socket/socket.socketer.go:361. Quick glance over the code tells me that the unbuffered error channel isn't being read from at any point and thus the goroutine is stuck indefinitely.

Ahh, thank you. I just changed that, I'll take a look today.

Are you calling browser.Close()?

So I think this time.After() is the culprit here, when that runs then the goroutine will zombie out. But I also didn't account for the socket going completely quiet either.

I expect that it's taking longer than a second to close the websocket because there isn't any activity. This PR should cover that case as well. Let me know if you have any other thougts.

As far as I understand it the problem is that the errCh channel in socket.Listen() (

errCh := make(chan error)
) never gets closed nor read from, causing any routine that writes into it to block indefinitely. And since socket.listen writes into it, well...

This is the line the goroutines are stuck in.

Oh, ok, I see, you are correct. It looks like there are two issues. I'll clean that up this morning.

I've restored the normal error behavior, let me know if you see anything else. Thanks!!