Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(driver): fix legacy runner hanging oopifs in some cases #14074

Merged
merged 4 commits into from
Jun 2, 2022

Conversation

connorjclark
Copy link
Collaborator

While investigating #13861, I noticed that the legacy runner takes a long time on the oopif-scripts.html smoke fixture. This is because the OOPIF target hangs forever, and is never loaded. This was made clear when the second iframe on the test page never rendered any content.

Turns out, we can't do Network.enable and await its response if the target is paused.

It seems like the iframe specific part of _handleTargetAttached may have always been busted? It's also possible that Chrome CDP internals changed underneath us.

I also added a clarifying comment in _handleTargetAttached noting that all that logic is only for OOPIFs.

@connorjclark connorjclark requested a review from a team as a code owner June 2, 2022 00:12
@connorjclark connorjclark requested review from adamraine and removed request for a team June 2, 2022 00:12
@adamraine adamraine mentioned this pull request Jun 2, 2022
6 tasks
@connorjclark connorjclark changed the title driver: fix order of commands to avoid hanging oopif targets core(driver): fix order of commands to avoid hanging oopif targets Jun 2, 2022
@connorjclark connorjclark changed the title core(driver): fix order of commands to avoid hanging oopif targets core(driver): fix legacy runner hanging oopif targets Jun 2, 2022
await Promise.all([
// Events from subtargets will be stringified and sent back on `Target.receivedMessageFromTarget`.
// We want to receive information about network requests from iframes, so enable the Network domain.
this.sendCommandToSession('Network.enable', event.sessionId),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this fix the issue? Does it guarantee that Network.enable finishes after the target is resumed?

Copy link
Collaborator Author

@connorjclark connorjclark Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The protocol doesn't respond to the Network.enable event until the underlying target has been resumed.

Copy link
Collaborator Author

@connorjclark connorjclark Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it guarantee that Network.enable finishes after the target is resumed?

We don't care when the response is acked... and the order of the commands is guaranteed to be processed in the
order we sent them, so we're good.

Copy link
Member

@brendankenny brendankenny Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The protocol doesn't respond to the Network.enable event until the underlying target has been resumed.

If that's the case, shouldn't it always have failed and not been flakey?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also confused on that point, I mention in the OP.

@connorjclark
Copy link
Collaborator Author

Update: I made a mistake when confirming this was an issue. I was accidentally testing things with this line commented out:

if (event.frame.parentId) return;

Without that line, all frames are set to be auto-attached/paused on start. I'm not sure what the difference really is, because the AttachedToTargetEvent for the OOPIF iframe in both cases looks the same.

So this isn't fixing a present issue, I guess, but seems good to do anyway. It may end up being necessary / helping with debugging #13861

@connorjclark
Copy link
Collaborator Author

connorjclark commented Jun 2, 2022

why did I comment that out? because in devtools all of these frame navigated events have a parentId, so I was curious what this line was even for. Turns out, without it OOPIFs hang (in legacy runner CLI).

@connorjclark connorjclark changed the title core(driver): fix legacy runner hanging oopif targets core(driver): fix legacy runner hanging oopifs in some cases Jun 2, 2022
@connorjclark connorjclark merged commit 4bc0b05 into master Jun 2, 2022
@connorjclark connorjclark deleted the fix-_handleTargetAttached branch June 2, 2022 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants