question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] page.waitForSelector fails when called during a redirect

See original GitHub issue

Context: System: OS: macOS 10.15.7 Memory: 226.13 MB / 32.00 GB Binaries: Node: 12.18.3 - /var/folders/sn/fccqtk995ll0h2b7wtp1z_z80000gr/T/fnm-shell-5071240/bin/node npm: 6.14.8 - /var/folders/sn/fccqtk995ll0h2b7wtp1z_z80000gr/T/fnm-shell-5071240/bin/npm Languages: Bash: 3.2.57 - /bin/bash

Describe the bug

Hi team. I’m seeing an issue with waitForSelector throwing an error in some cases. When I call it during a series of server redirects, it’s throwing. However, if I use waitForTimeout to let the redirects finish, and then call waitForSelector, everything is fine.

// fill out a form and click "submit"
// this process redirects several times through various hostnames
await page.waitForSelector('.logo');

When I run this, I see this error:

UnhandledPromiseRejectionWarning: page.waitForSelector: Evaluation failed: TypeError: injected.pollRaf is not a function
    at eval (__playwright_evaluation_script__217:3:25)
    at UtilityScript.callFunction (__playwright_evaluation_script__206:305:24)
    at UtilityScript.<anonymous> (__playwright_evaluation_script__227:1:44)

Or sometimes this error:

UnhandledPromiseRejectionWarning: page.waitForSelector: Protocol error (Runtime.callFunctionOn): Could not find object with given id

I’ve tried creating a minimal repro of this issue, but I’m struggling to get it to happen outside of my staging environment. Any suggestions for a potential way to repro this would be much appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dgozmancommented, Feb 23, 2021

@pixelastic This should be fixed with the next version of Electron itself, once the fix from Chromium is rolled in. So, if you plan to upgrade your Electron to the next version, things should work. I believe that Electron 12 that is based on Chromium M89 will have the fix.

1reaction
dgozmancommented, Oct 5, 2020

When running against the ToT Playwright, I get the Could not find object with given id error in response to Runtime.callFunctionOn.

This seems to be caused by remote object ids clashing between different processes, e.g. {\"injectedScriptId\":4,\"id\":1}. This could also explain the pollRaf is not a function error, in the case objectId is valid but points to a different type of object (not InjectedScript). From what I can see, WebKit might suffer from the same problem when swapping processes on navigation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Puppeteer - Handlin page.waitForSelector() fails
waitForSelector () fails, it throws an error. Since this is run inside an async function if leads straight to the catch portion of...
Read more >
Running into errors due to a redirect and unsure of how to ...
I believe page.waitForSelector is not asynchronous (yet) - try putting it outside of/in front of the Promise.all calls; I'm under the impression ...
Read more >
API Reference — Pyppeteer 0.0.25 documentation
newPage() creates a page in the default browser context. If a page opens another page, ... goto() either raise error or return a...
Read more >
Page.goto() method - Puppeteer
The status code for such responses can be retrieved by calling response.status(). NOTE: page.goto either throws an error or returns a main resource...
Read more >
Navigating & waiting - Checkly
Navigating Initial navigation to any page is pretty much the same for ... page.waitForSelector(). This method waits for an element to appear in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found