-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix execution context setting for iframes #1254
Conversation
b398508
to
3405f11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I still see the same error (after running the user's script with this branch) 😭 The reason you might not see the error is probably because of a race condition since the script uses a lot of sleep
s.
a752709
to
349c9e0
Compare
Yep, you are correct, the same error that was posted in the original post still occurs 😢, when ran in headless mode: panic: GoError: dispose: disposing element with ID -28511178728990825.29.1: Cannot find context with specified id (-32000) However this same issue doesn't occur in headful mode with: K6_BROWSER_HEADLESS=false k6 run e2e/test.js Without this fix, in headful mode, the test ends up in an infinite loop when waitForExecutionContext is called. I think it's still a valid fix, but I will need to go back to the post and correct my assumption. I'll then look at resolving the original error 👍 |
On the On this fix's branch, when I run this fix in headful mode, I receive the following error. I also noticed that the Chromium processes didn't shut down.
What do you suggest about the next steps for issue #1252? I mean we can merge this PR, but keep the issue open. Or? |
This shouldn't happen since the fix was merged into
In the latest version this points to a comment and not to a call to |
🤦 You're right. It somehow cached the version. I should have checked the versions in the stack trace. Apologies for the noise. WDYT about this since the fix only applies to the headful version?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
🙂 👍
I believe that this PR does fix the issue it is attached to (#1252), and so we can close that issue once this PR is merged. Unfortunately it doesn't fix the original issue from the community post, but there is an open issue for that already #1144. I plan to work on that next. |
It doesn't make sense for this operation to continue when the frame is not present, so return early. If the frame is present continue as normal.
The events are as follows when an iframe is attached: 1. execCtx for about:blank for new frame is set; 2. execCtx for navigated frame with url is set; 3. original about:blank execCtx is destroyed. If we only work with the original execCtx, then it will be destroyed by the 3rd event. To prevent this we overwrite the original one with the new one in the 2nd event. What this means is that we do not end up in an infinite loop when waitForExecutionContext is called.
349c9e0
to
d02f88d
Compare
What?
This fixes a problem with setting the execution context when testing a website that uses iframes. Without this fix it could end up in an infinite loop when
waitForExecutionContext
is called.Why?
There is a race condition when it comes to attaching iframes and the execution context that apply to these frames. What usually occurs is:
This is the order of events when iframes are in use on a site, and so it is safe to nil the original execution context and overwrite it with the second one.
The exec context destroyed event will not remove the new exec context since the ids do not match.
If we didn't overwrite the first execCtx with the new one, then waitForExecutionContext could end up waiting indefinitely since all execCtx were destroyed.
Reference: Playwright
Checklist
Related PR(s)/Issue(s)
Updates: #1252
Since this fixes an interaction with
iframe
s, we now see morepanic: GoError: dispose: canceled
errors, which there is an open issue for: #1089.