Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mdan's avatar
Level 1

Browsershot Navigation Timeout on Prod

Hey guys, currently im having a weird issue with the navigation timeout for which I didnt find any fix yet anywhere else. So I hope I find some help maybe here. For the prod machine itself im using Ubuntu 20.04.1 LTS together with PHP 8.3 and Apache2. The problem appears for Laravel 11.30, spatie/browsershot 4.3.0, npm 9.2.0, composer 2.8.2.

The code itself works fine for like maybe a week and then suddenly without any other error (apache2 or PHP related) just dies for no reason. If I had to guess I would say it might be a PHP related error, since I really cant think for any other reason why the code itself should work for around a week and then suddenly die. The only way to workaround this problem is a full reboot of the VM, but that also doesnt work everytime. The code for the pdf generation itself is in a dispatchable job. So when a user submits the form certain jobs are getting dispatched in the background.

I also did already check if there is a possibility to declare the default navigation timeout, but I couldnt find anything other then the timeout method itself, which sadly doesnt help for this problem.

Code in Controller:

 Browsershot::html(view('pdf.' . $viewName, ['data' => $data])->render())
            ->noSandbox()
            ->userAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36')
            ->ignoreHttpsErrors()
            ->emulateMedia('print')
            ->waitUntilNetworkIdle()
            ->setOption('args', ['--disable-web-security'])
            ->waitForSelector('.flex')
            ->format('A4')
            ->save($filePath . '/' . $viewName . '.pdf');

Error:

Any guesses or tips are hardly appreciated. This problem is getting on my nerves for quite a while now.

1 like
0 replies

Please or to participate in this conversation.