puppeteer: [Bug]: exposeFunction() sometimes gets stuck waiting forever, yet there's no documented timeout parameter.
Bug description
Steps to reproduce the problem:
console.log("Exposing function...");
await page.exposeFunction('myFunction', () => {
// whatever...
return;
});
console.log("Function exposed.");
About 80% of the times this works as expected. Occasionally, however, this will get stuck waiting forever after this output:
Exposing functions...
As far as I understand, exposing a function is an instantaneous operation except for the part of sending a request to the browser (or in my case to chrome.browserless.io) and getting a response from it, so the only case where I can imagine this remaining stuck waiting without throwing an exception, is a network issue or the browser failing to respond.
But then there should be a configurable timeout parameter and I don’t see any documented.
Puppeteer version
13.4.0
Node.js version
17.0.1
npm version
8.1.0
What operating system are you seeing the problem on?
Linux
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 42
I have opened a PR based on https://github.com/puppeteer/puppeteer/pull/11600 based on findings from https://github.com/puppeteer/puppeteer/issues/8106#issuecomment-1870508448 Please give the patch a try to see if it helps.
Thanks for this example. In this case, it looks like one of several frames on the site does not have the execution context properly reported by the browser. That sounds like a bug in the browser. I wonder if other reports have the same underlying issue?
i switched to playwright and it works well