-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Protocol error (Page.captureScreenshot): Target closed when I try take screenshot #1385
Comments
|
I get |
@kauecastro I believe this line: let image = this.page.screenshot({fullPage: true, type: 'jpeg'}); Is missing an await: let image = await this.page.screenshot({fullPage: true, type: 'jpeg'}); So the rest of your code is probably executing synchronously and not actually waiting for the screenshot to complete. |
We're using docker container like that:
And inside this container we're getting an error In a local machine, everything is fine. |
I can confirm that this only happens on large pages. It also happens only when I run it on my remote server that has low processing power and RAM. It works fine when I run it on personal machine. I suspect the RAM on my server wasn't enough. If puppeteer can stream the data instead of holding it all in memory, it may solve the issue? |
@seekshiva a docker container that I ran on my local machine has no RAM or CPU limit, but outside a container - everything is ok |
I was previously running the script on the $5 digital ocean instance with 512mb RAM.. I've upgraded to 3GB RAM and the script is able to generate screenshots without any issues. |
The issue in the OP seems to be addressed by the comment. |
@aslushnikov This not solved my issue. |
I was having this issue in MacOS. It got fixed after I started saving the screenshot under |
Running this example code:
I get the following error output:
0|era-moni | Error: Protocol error (Page.captureScreenshot): Target closed.
0|era-moni | at Session._onClosed (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/puppeteer/lib/Connection.js:209:23)
0|era-moni | at Connection._onClose (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/puppeteer/lib/Connection.js:116:15)
0|era-moni | at emitTwo (events.js:106:13)
0|era-moni | at WebSocket.emit (events.js:194:7)
0|era-moni | at WebSocket.emitClose (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/ws/lib/WebSocket.js:213:10)
0|era-moni | at _receiver.cleanup (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/ws/lib/WebSocket.js:195:41)
0|era-moni | at Receiver.cleanup (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/ws/lib/Receiver.js:520:15)
0|era-moni | at WebSocket.finalize (/home/ubuntu/project/ra-monitors/era-monitor-browser/node_modules/ws/lib/WebSocket.js:195:22)
0|era-moni | at emitNone (events.js:91:20)
0|era-moni | at Socket.emit (events.js:188:7)
The text was updated successfully, but these errors were encountered: