Skip to content

Commit

Permalink
Add context done case to waitForEvent
Browse files Browse the repository at this point in the history
If the context is done before all the tasks are read from the queue,
the remaining tasks on the queue will not be read and so the done
channel will not be closed causing the goroutine to wait forever.

This is solved by adding a context.Done() check so that when the
context is closed we can carry on with shutting down of the iteration.
  • Loading branch information
ankur22 committed Oct 25, 2024
1 parent 67d6dc8 commit 135e886
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion browser/browser_context_mapping.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package browser

import (
"errors"
"fmt"
"reflect"

Expand Down Expand Up @@ -126,7 +127,12 @@ func mapBrowserContext(vu moduleVU, bc *common.BrowserContext) mapping { //nolin
close(c)
return nil
})
<-c

select {
case <-c:
case <-ctx.Done():
err = errors.New("iteration ended before waitForEvent completed")
}

return rtn, err //nolint:wrapcheck
}
Expand Down

0 comments on commit 135e886

Please sign in to comment.