You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on #929, I noticed that in getDefaultBrowserContextOrByID we return the defaultContext when the requested context with the given id is not found. I changed this to panic when this occurred, but it panicked when running multiple k6 test runs (with multiple k6 instances) against a single chrome instance.
My guess as to why a browserContext cannot be found when we receive a onAttachedToTarget event is because each of the k6 instances mirrors the pages from all other k6 instances, but we're not mirroring the creation of the browserContexts. It would be great if we didn't also have to create the page that is associated with a different k6 instance and not the current one 🤔
Experiment
I ran a quick experiment where i returned nil from getDefaultBrowserContextOrMatchedID:
and the caller would have to check for a nil browserCtx and return early, avoiding the need to create the requested page:
ifbrowserCtx==nil {
return// Ignore requests to attach target for other k6 instances
}
Which actually worked! So maybe there is a possibility of making this less complex and not needing to track pages from other k6 instances in the current k6 instance.
Are there other side affects of not creating a page when we can't find the browserContext?
Can we avoid/skip similar such cases with other objects or requests when objects aren't found in the current k6 instance as they only exist in another k6 instance?
Can we remove the need for defaultContext?
Any other ideas?
The text was updated successfully, but these errors were encountered:
Description
While working on #929, I noticed that in getDefaultBrowserContextOrByID we return the
defaultContext
when the requested context with the given id is not found. I changed this to panic when this occurred, but it panicked when running multiple k6 test runs (with multiple k6 instances) against a single chrome instance.My guess as to why a
browserContext
cannot be found when we receive aonAttachedToTarget
event is because each of the k6 instances mirrors thepage
s from all other k6 instances, but we're not mirroring the creation of thebrowserContexts
. It would be great if we didn't also have to create thepage
that is associated with a different k6 instance and not the current one 🤔Experiment
I ran a quick experiment where i returned
nil
fromgetDefaultBrowserContextOrMatchedID
:and the caller would have to check for a nil
browserCtx
and return early, avoiding the need to create the requestedpage
:Which actually worked! So maybe there is a possibility of making this less complex and not needing to track
page
s from other k6 instances in the current k6 instance.Originally posted by @ankur22 in #929 (comment)
Task
page
when we can't find thebrowserContext
?defaultContext
?The text was updated successfully, but these errors were encountered: