puppeteer: [Bug]: ProtocolError: Network.getResponseBody timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.

Bug expectation

I expect this error to be managed by an exception handler, and not crash the app.

this is the full stack-trace:

ProtocolError: Network.getResponseBody timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at new Callback (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:61:35)
    at CallbackRegistry.create (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:106:26)
    at Connection._rawSend (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:216:26)
    at CDPSessionImpl.send (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:425:78)
    at next (/root/server/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:34:41)
    at CDPSessionImpl.send (/root/server/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:67:18)
    at /root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPResponse.js:99:100
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HTTPResponse.text (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/api/HTTPResponse.js:98:25)
    at async HTTPResponse.json (/root/server/node_modules/puppeteer-core/lib/cjs/puppeteer/api/HTTPResponse.js:110:25)

Bug behavior

  • Flaky
  • PDF

Minimal, reproducible example

cannot share the example :)

Error string

ProtocolError: Network.getResponseBody timed out. Increase the ‘protocolTimeout’ setting in launch/connect calls for a higher timeout if needed.

Puppeteer configuration

No response

Puppeteer version

latest

Node version

latest

Package manager

npm

Package manager version

latest

Operating system

Linux

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15

Commits related to this issue

Most upvoted comments

@PiyushSuneja02

If you are using puppeteer < 22.x.x try something like this:

const browser = await puppeteer.launch({
      headless: true,
      args: ['--no-sandbox', '--disable-setuid-sandbox'],
      executablePath: process.env.NODE_ENV === 'production' ?
          process.env.PUPPETEER_EXECUTABLE_PATH :
          puppeteer.executablePath(),
});

or

const browser = await puppeteer.launch({
      headless: 'old',
      args: ['--no-sandbox', '--disable-setuid-sandbox'],
      executablePath: process.env.NODE_ENV === 'production' ?
          process.env.PUPPETEER_EXECUTABLE_PATH :
          puppeteer.executablePath(),
});

if you are in v22 or above:

const browser = await puppeteer.launch({
      headless: 'shell',
      args: ['--no-sandbox', '--disable-setuid-sandbox'],
      executablePath: process.env.NODE_ENV === 'production' ?
          process.env.PUPPETEER_EXECUTABLE_PATH :
          puppeteer.executablePath(),
});

As far as I understand from reading here, is the new headless mode generates hidden platform windows, and that could be the source of the problem on docker stripped environments. Setting the headless mode to the old one doesn’t try to build those platform windows, and that’s why I think this works.

Hope this helps you. Cheers.

HEllo did you find solution, I have same problem?

In my case this can be bypassed by setting headless: true instead of headless: ‘new’, but then I got a nasty warning.

This does not happen when the code runs locally, only when it runs on docker using ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser