Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix read/write race condition for edge case
This mutex is only needed in an edge case where we have multiple instances of k6 connecting to the same chrome instance. In this case when a page is created by the first k6 instance, the second instance of k6 will also receive an onAttachedToTarget event. When this occurs there's a small chance that at the same time a new context is being created by the second k6 instance. So the read occurs in getDefaultBrowserContextOrMatchedID which is called by onAttachedToTarget, and the write in NewContext. This mutex protects the read/write race condition for this one case.
- Loading branch information