No response from puppeteer

Hello everyone. I have an application on Next.js v 14.2.3. There I am using Puppeteer v 22.12.1. The application has been running stable for about half a year now, no changes have been made to the puppeteer part of the application. But after yesterday’s deployment the initialisation of page creation in the browser stopped responding.

const browser = await puppeteer.launch({
headless: true,
executablePath: executablePath(),
args: [--no-sandbox],
protocolTimeout: 60000 * 4,
});

const page = await browser.newPage();

await browser.newPage() does not respond and gives a timeout error after 4 minutes : ProtocolError: Network.enable timed out. Increase the ‘protocolTimeout’ setting in launch/connect calls for a higher timeout if needed.

Has anyone encountered this problem ? Yesterday fly published fly.proxy update could it affect ?

I am having the exact same issue and cannot resolve it yet. Did you find a solution?

Edit:
you can enable dumpio to see more errors.

const browser = await puppeteer.launch({
    executablePath:
      NODE_ENV !== "development"
        ? CHROME_EXECUTABLE_PATH || "/usr/bin/chromium"
        : undefined,
    args: ["--no-sandbox", "--disable-setuid-sandbox", "--disabled-gpu"],
    dumpio: true,
  });

It actually shows quite a few errors:

2024-08-09T08:15:45Z app[7815dedb06e268] ams [info][362:387:0809/081545.898737:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
2024-08-09T08:15:45Z app[7815dedb06e268] ams [info][362:391:0809/081545.974104:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
2024-08-09T08:15:45Z app[7815dedb06e268] ams [info][362:391:0809/081545.976275:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.115265:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.120459:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.123918:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.125058:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.320154:ERROR:angle_platform_impl.cc(44)] Display.cpp:1083 (initialize): ANGLE Display::initialize error 12289: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info]ERR: Display.cpp:1083 (initialize): ANGLE Display::initialize error 12289: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.349576:ERROR:gl_display.cc(497)] EGL Driver message (Critical) eglInitialize: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.351343:ERROR:gl_display.cc(772)] eglInitialize Default failed with error EGL_NOT_INITIALIZED
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.355589:ERROR:gl_display.cc(806)] Initialization of all EGL display types failed.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.381871:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.464493:ERROR:angle_platform_impl.cc(44)] Display.cpp:1083 (initialize): ANGLE Display::initialize error 12289: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info]ERR: Display.cpp:1083 (initialize): ANGLE Display::initialize error 12289: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.468292:ERROR:gl_display.cc(497)] EGL Driver message (Critical) eglInitialize: Could not open the default X display.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.469773:ERROR:gl_display.cc(772)] eglInitialize Default failed with error EGL_NOT_INITIALIZED
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.472447:ERROR:gl_display.cc(806)] Initialization of all EGL display types failed.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.473661:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed.
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][401:401:0809/081546.554149:ERROR:viz_main_impl.cc(166)] Exiting GPU process due to errors during initialization
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.847705:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
2024-08-09T08:15:46Z app[7815dedb06e268] ams [info][362:387:0809/081546.848391:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Hi, having the same issue. Did anyone find a fix for this?

Hey everyone, sharing in case helpful for others - I was able to fix the problem by using headless: 'old mode for Puppeteer.

Here are the specific puppeteer options I used:

      headless: 'old',
      args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-dev-shm-usage',
        '--disable-accelerated-2d-canvas',
        '--no-first-run',
        '--no-zygote',
        '--disable-gpu',
        '--disable-software-rasterizer',
      ],
      protocolTimeout: 60000, // 60 seconds
      timeout: 60000, // 60 seconds

Someone else posted this solution on a Puppeteer Github Issue thread, that I took inspiration from - [Bug]: ProtocolError: Network.getResponseBody timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. · Issue #10091 · puppeteer/puppeteer · GitHub

2 Likes

Was this an issue with projects that didn’t lock down their puppeteer version? OP is using v22, that shouldn’t have the same problem as the issue you linked?

I managed to fix it by following some examples from pupeteer on how to setup the dockerfile. This is basically everything I have changed.
Here is the PR we fixed it in: fix: pdf generator crash by DonKoko · Pull Request #1235 · Shelf-nu/shelf.nu · GitHub

Hope this helps. GL

Hey, everybody. I apologise for the late reply. The solution is found, you need to run in shell mode and add all these arguments.

   const mainBrowser = await puppeteer.use(StealthPlugin()).launch({
        headless: app === 'shell'
        executablePath: chromePath,
        args: [
            '--no-sandbox',
            '--disable-setuid-sandbox',
            '--disable-dev-shm-usage',
            '--disable-gpu',
            '--no-zygote',
            '--disable-software-rasterizer',
            '--disable-features=VizDisplayCompositor'
        ],
        protocolTimeout: 60000 * 4,
    });