1

I have pyppeteer code that browses around. Let's assume it only clicks on a tags.

It runs fine on my local Windows machine, but breaks whenever I run it remotely on a Linux server. Same conda env, same code.

The relevant part of my code, simplified, looks like:

async def act(self):
    element = self.element

    async def get_action():
        tag_name = await self.page.evaluate(
            'elem => { return elem.tagName.toLowerCase(); }',
            element)
        action = None
        if tag_name == 'a':
            action = element.click()
        else:
            action = async_pass()
        return action

    async def get_action_future():
        # gather syntax based on:
        # https://miyakogi.github.io/pyppeteer/reference.html#pyppeteer.page.Page.click
        action = await get_action()
        future_action = asyncio.gather(
            action,
            asyncio.sleep(0.001),  # dirty, dirty work-around, doesn't work nicely otherwise
        )
        waited_future = await asyncio.shield(future_action)
        if waited_future[0] is None:
            await self.page.waitForNavigation(self.wait_options)
        return None

    await get_action_future()

It runs fine on my Windows machine. When I start it on a Linux machine, it starts off OK, whether there's navigation or not. Then, after a few navigation clicks, I'm getting a timeout, then another error:

Error encountered: Navigation Timeout Exceeded: 20000 ms exceeded.
# then I trigger the element selector and the act method again, wrapped in try/except
Error encountered: Protocol Error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.

I'm stuck on this problem for a while and would appreciate any help!

My environment includes: python=3.6, pyppeteer=0.0.25.

BTW: I noticed that this question has a similar error. BUT, the error is different (Protocol error (Page.navigate): Target closed instead of Protocol Error (Runtime.callFunctionOn)), as well as the environment (node.js, Puppeteer, etc.).

YardenR
  • 301
  • 2
  • 13
  • Did you try to set higher timeout? See example [here](https://github.com/miyakogi/pyppeteer/issues/66). – Mikhail Gerasimov Dec 25 '18 at 12:54
  • Hi @MikhailGerasimov, yes I have. I am passing a `timeout` argument. Even at ridiculously long timeouts (100 secs), it still crashes. `pyppeteer.errors.NetworkError: Protocol error Runtime.callFunctionOn: Target closed.` or `Error encountered: Protocol Error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.` – YardenR Dec 25 '18 at 13:47
  • @YardenR - Did you manage to find a solution for this? I'm experiencing the exact same issue and am wondering if it's to do with packages missing on the server – Calum Oct 05 '21 at 12:00
  • @Calum I did not. From what I recall, I think it was linked to a Chromium bug? I'm not sure, it was a while ago :D I'm not actively working on this project anymore. – YardenR Oct 06 '21 at 11:49
  • Thanks for the update. I switched to Selenium and it's working fine – Calum Oct 06 '21 at 12:17

1 Answers1

0

It seems that Pypepeteer is no longer maintained. I was experiencing the same issue and migrated to Selenium which is working well.

Calum
  • 104
  • 11