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 5 years ago
  • Reactions: 5
  • Comments: 42

Most upvoted comments

i switched to playwright and it works well

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?

We’re marking this issue as unconfirmed because it has not had recent activity and we weren’t able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

We’re marking this issue as unconfirmed because it has not had recent activity

This is stupid. If there hasn’t been any recent activity, then do some activity and fix it, or at least start investigating it. That’s not a reason for closing a bug

and we weren’t able to confirm it yet.

There’s no indication that you tried, there has been no response from any human being on your side. Plus, multiple users have confirmed it.

It will be closed if no further activity occurs within the next 30 days.

That’s even more stupid, I don’t even know where to start.

We’re marking this issue as unconfirmed because it has not had recent activity and we weren’t able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.