-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TargetCloseError: Protocol error (Page.printToPDF): Target closed #100
Comments
Thanks for reporting @robgaskell. From my point of view, I don't really know how I should reproduce this error on my side. The error message would suggest to me, that you might create PDFs with "thousands" of pages or that sidecar-browsershot or AWS Lambda has some garbage collection issue, where "old" instances linger around and break the browser. A quick search for "protocolTimeout" revealed the following links:
The upstream spatie/browsershot package doesn't support setting Here's also the relevant docs for puppetteer: https://pptr.dev/api/puppeteer.browserconnectoptions/ |
Thank you for your reply. I have a report that I am using for testing which is typical for the kind of PDF's we need to produce. This report has a html source of approx 14MB and when it does generate the PDF (using v1.9.1) it is 159 pages, primarily made up of a large table. I am aware that Chrome is not particularly fast at rendering table data. However the report does consistently generate correctly under v1.9.1 and fails in more recent versions. I wonder if the default settings for Chrome changed with the changing of the layer in #85 Thank you for the links you supplied, I will have a read through these. |
@robgaskell Will add some tests for this in the next few days to hopefully reproduce this issue.
#85 was quite the version jump. I think we went from v104 to v116. Could well be that something has been updated internally inside of Chrome. |
I was finally able to reproduce this issue. I generated an enormous 20 MB HTML file and used that the source of the Browsershot request. Here's my code.
This resulted in the same error you got @robgaskell.
As you mentioned, Puppeteer itself suggests increasing spatie/browsershot does not have a dedicated BrowsershotLambda::readHtmlFromS3('example-read-from.html')
->timeout(300)
->setOption('protocolTimeout', 600_000)
->save('example.pdf'); However, I get the same error message after using |
The {
path: '/tmp/browsershot',
args: [
'--allow-pre-commit-input',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-extensions-with-background-pages',
'--disable-component-update',
'--disable-default-apps',
'--disable-dev-shm-usage',
'--disable-extensions',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-sync',
'--enable-automation',
'--enable-blink-features=IdleDetection',
'--export-tagged-pdf',
'--force-color-profile=srgb',
'--metrics-recording-only',
'--no-first-run',
'--password-store=basic',
'--use-mock-keychain',
'--disable-domain-reliability',
'--disable-print-preview',
'--disable-speech-api',
'--disk-cache-size=33554432',
'--mute-audio',
'--no-default-browser-check',
'--no-pings',
'--single-process',
'--disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,site-per-process',
'--enable-features=NetworkServiceInProcess2,SharedArrayBuffer',
'--hide-scrollbars',
'--ignore-gpu-blocklist',
'--in-process-gpu',
'--window-size=1920,1080',
'--disable-webgl',
'--allow-running-insecure-content',
'--disable-setuid-sandbox',
'--disable-site-isolation-trials',
'--disable-web-security',
'--no-sandbox',
'--no-zygote',
'--headless'
],
viewport: { width: 800, height: 600 },
s3Source: {
path: 'example-read-from.html',
region: 'us-east-2',
bucket: 'sidecar-us-east-2-xxxxxxxxx'
},
timeout: 300000,
protocolTimeout: 300000000,
executablePath: '/tmp/chromium'
} Now I wonder if this is a bug in Chromium or we're doing something wrong. |
FWIW Updating browsershot to ^4.0 and sidecar-browsershot to ^2.0 seems to have fixed this "Target closed" issue for us. |
Thanks for the update @drfraker. |
This worked! Thank you @drfraker |
Agreed, upgrading to the latest release has fixed this issue for us too. Thanks |
Since upgrading to version > 1.9.1 we have frequently been getting one of the following exceptions when attempting to generate PDF's using the package:
Error: Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js' TargetCloseError: Protocol error (Page.printToPDF): Target closed at CallbackRegistry.clear (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:146:36)
Error: Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js' ProtocolError: Page.printToPDF timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. at <instance_members_initializer> (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:49:14)
I have since downgraded back to v1.9.1 and the exceptions have all stopped happening.
Any idea what could be causing these problems and how to overcome them?
I have tried to find and configure the protocolTimeout setting as suggested in the exception message but I couldn't find any information to help with this, so either my attempts to set it were wrong or were unsuccessful as a solution as whatever I tried made no difference to the outcome.
The text was updated successfully, but these errors were encountered: