grafana / xk6-browser

The browser module adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol to k6.
https://grafana.com/docs/k6/latest/javascript-api/k6-browser/
GNU Affero General Public License v3.0
344 stars 41 forks source link

Fix memory leak caused by taskqueue closing before all tasks are executed #1493

Closed ankur22 closed 1 month ago

ankur22 commented 1 month ago

What?

Adding a context.Done() check so that when the context is closed we can carry on with shutting down of the iteration and not wait for the task to run (which will not happen since the taskqueue will have also been shutdown either from here, or here).

Why?

If the taskqueue is closed before all the tasks are read from the queue, the remaining tasks on the queue will not be read and executed and so the done channel will not be closed causing the goroutine to wait forever.

Checklist

Related PR(s)/Issue(s)

Updates: https://github.com/grafana/xk6-browser/issues/1480