2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Chrome-php で”operation timed out after 5s.”問題のひとつの対策 

2
Posted at

↑がすばらしいのと、
<div style="break-after: page;"> </div>
↑の改ページでばんばんレイアウトを整えて、順調にPDF作成していたところ、なぜか、ちょいちょい

operation timed out after 5s.

になって、PDF出力できないときがあった。。

更新ボタン連打してたら治ったりすることもあったので、地味に放置してたけど、出力容量が増えるにつれ、この問題の発生頻度は限りなく100%に近づいた。。

英語のサイトを調べてもいまいち。。RAMを増やせばいけるとか。。

blade で出力すれば見れることは見れるが、ページの切り替わりの部分がわからんので、どうしてもちょこちょこPDF出力したい。。。全体像がつかめん。。

あかん.php
use HeadlessChromium\BrowserFactory;

$browserFactory = new BrowserFactory();

$browser = $browserFactory->createBrowser([
    'connectionDelay' => 0.8,     // 接続遅延
    'debugLogger' => 'php://stdout',
    'windowSize' => [1920, 1080],
    'noSandbox' => true,          // コンテナ環境などで必要な場合
    'enableImages' => false,
    'userDataDir' => '/tmp',
    'headless' => true,
    'timeout' => 15               // ★タイムアウト延長(秒)
]);

とかやって猶予を延長しても、あかん。。

しかもひどいときは

operation timed out after 1s.

とか出るし。。 1秒かい。。

で、結局、

vendor\chrome-php\chrome\src\PageUtils\AbstractBinaryInput.php
public function saveToFile(string $path, int $timeout = 5000): void

5000 → 10000

とかやったらいけた。

ファイルの容量が大きいとなってくるのかな。36ページぐらいあるけど。

2
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?