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
[x] I have performed a self-review of my code
[ ] I have added tests for my changes
[ ] I have commented on my code, particularly in hard-to-understand areas
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