-
Notifications
You must be signed in to change notification settings - Fork 43
Go panic: cannot create frame session #125
Comments
I couldn't find the root cause of this after dealing with hundreds of print statements and debugging trials. |
Findings:
I have a draft PR for this (not ready for review), working on it. I added a lot of logging statements to diagnose the root cause. And they are super helpful. |
Today's findings:
import launcher from 'k6/x/browser';
export default function() {
let browser = launcher.launch('chromium', {
debug: false,
devtools: false,
headless: false,
slowMo: '50ms', // 500ms breaks it
timeout: '30s',
});
let context = browser.newContext({ });
let page = context.newPage();
page.goto('https://vistaprint.ca', { waitUntil: 'domcontentloaded' });
page.waitForSelector("//span[text()='Business Cards']");
let elem = page.$("//span[text()='Business Cards']");
elem.click();
page.waitForSelector("//a[text()='Browse designs']");
elem = page.$("//a[text()='Browse designs']");
elem.click();
page.waitForSelector("li.design-tile");
let elems = page.$$("li.design-tile");
page.waitForSelector("li.design-tile");
} I also wrote a Playwright script that never uses sleep and works flawlessly. Of course, it uses promises, unfortunately, which we don't have. const { test } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://vistaprint.ca', { waitUntil: 'domcontentloaded' });
console.log("Current Page:", await page.title())
let elem = await page.$("//span[text()='Business Cards']");
await elem.click();
console.log("Current Page:", await page.title())
elem = await page.$("//a[text()='Browse designs']");
await elem.click();
console.log("Current Page:", await page.title())
let elems = await page.$$("li.design-tile");
console.log(`Found ${elems.length} design options.`);
}) |
I believe I solved the error (see this): Now, I'm trying to add a proper test to validate it without using PS: I changed the name of the PR because we no longer witness context-canceled errors (I checked this with Tom's script). |
There were missing locks for execution contexts. This fix adds a lock-based management for locks and uses an internal goroutine to track whether an execution context is ready to use. For now, it uses an infinite for loop with sleep. This is not effective. So it should be fixed with something better. There are some TODOs in the code that should be investigated. Also the tests are missing from this commit. So they should be added as well. Fixes #125
Playwright cannot run this script and randomly fails as well 🤷 @tom-miseur can you provide us a script to reproduce the issue? We need a script that:
So we can locally reproduce the problem and fix it if there is one. |
The error was: panic: interface conversion: interface {} is nil, not *common.ElementHandle The cause of the error was trying to assert a nil result in Frame.document to *ElementHandle. Of course, this is probably the surface error. There may be other causes for it, or maybe not. It was hard to test Frame, so I used an abstraction called FrameExecutionContext. There are a lot of problems are happening with execution contexts. See: #125 and #49, for example. So, it's better to make them testable, starting here. Fixes #53
There were missing locks for execution contexts. This fix adds a lock-based management for locks and uses an internal goroutine to track whether an execution context is ready to use. For now, it uses an infinite for loop with sleep. This is not effective. So it should be fixed with something better. There are some TODOs in the code that should be investigated. Also the tests are missing from this commit. So they should be added as well. Fixes #125
We've been noticing this error recently from Tom's updated script:
The first
Cannot find context with specified id
is the same error from #49, but now it pretty much happens constantly. So yay, it can be reproduced 😄The second
cannot create frame session
panic is because the context was canceled. We're not sure if this is a regression or if a site change has exposed it. Regardless, it shouldn't happen.The text was updated successfully, but these errors were encountered: