How to Increase Timeout Value in Puppeteer When Waiting for XPath Component to Change?

This topic was automatically generated from Slack. You can find the original thread here.

Hello, first I would like to thank you for the availability of Puppeteer!
I have a scenario where I have to wait almost 2 minutes for an XPath component to change its value.
However, I’m getting the error: ProtocolError | Waiting for selector failed: Runtime.callFunctionOn timed out.
Could you guide me on how to increase this timeout value?
thank you very much !

Hi Marcelo, glad to hear you’ve found our Puppeteer native support.

A couple of follow questions:

  1. Have you increased your workflow’s execution timeout settings? By default it’s 30 seconds per execution, so it’ll need to be increased in this case.
  2. Can you share the code that’s attempting to locate this element? I just want to double check that you’re passing in a timeout amount.
  1. yes, to 180 secs
  1. page.setDefaultTimeout(120000);
    await page.waitForXPath(selector7);

Thanks, unfortunately this seems like it may be a bug within this particular version of Puppeteer that we bundle in @pipedream/browsers (puppeteer v19.8.0)

The values you’re sharing match the original posters in the GH issue.

Have you noticed that the timeout occurs at exactly 30 seconds into the step’s execution?

Also, did you try passing a timeout definition to the waitForXPath() method? Meaning await page.waitForXPath(selector7, { timeout: 120000 })

yes I tried, it didn’t work

I found this issue [Bug]: ProtocolError: Target.createTarget timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. · Issue #10144 · puppeteer/puppeteer · GitHub
but I don’t know if I can run the puppeteer.launch command inside Pipedream

Nice find, that could potentially fix it. Yes, you can pass arbitrary options to the puppeteer.launch() command through the Pipedream @pipedream/browsers package:

Could you try passing { protocolTimeout: 240000 } to puppeteer.browser() like puppeteer.browser({ protocolTimeout: 240000 })?

it works ! thanks a lot Pierce !

Awesome :slightly_smiling_face: glad to hear that. We’ll make an update to the package to increase this timeout by default

Just an update for anyone finding this thread in the future, we have set the default protocol timeout on the constructor for both pre-built Puppeteer actions as well as the import { puppeteer } from '@pipedream/browsers' package.

You can still override it if you need a longer timeout time, but the default is 240000: