puppeteer: Seeing "Error: not opened at WebSocket.send" during simple usage

We have deployed a very simple instance of Puppeteer to the cloud using docker. Everything works perfectly in the beginning:

  • Chromium is built correctly
  • Chromium is launched with no errors
  • Requests to puppeteer are issued to:
    • Open a new page
    • Evaluates a very simple script (to scrape some text)
    • Then closes the page

I am able to get a few successful requests out of puppeteer, but after a bit, I see the following error

ERROR: Error: not opened at WebSocket.send (/usr/src/app/node_modules/ws/lib/WebSocket.js:355:18) at Connection.send (/usr/src/app/node_modules/puppeteer/lib/Connection.js:72:14) at Browser.newPage (/usr/src/app/node_modules/puppeteer/lib/Browser.js:44:47) at _callee$ (/usr/src/app/lib/utils/chrome.js:53:22) at tryCatch (/usr/src/app/node_modules/regenerator-runtime/runtime.js:65:40) at Generator.invoke [as _invoke] (/usr/src/app/node_modules/regenerator-runtime/runtime.js:303:22) at Generator.prototype.(anonymous function) [as next] (/usr/src/app/node_modules/regenerator-runtime/runtime.js:117:21) at step (/usr/src/app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /usr/src/app/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13 at <anonymous>

and the chromium/puppeteer appears to crash (meaning I continually receive the same error when attempting to create a new page on a new request)

Any ideas here?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 37 (7 by maintainers)

Most upvoted comments

Some of the reports in the thread might be related to small /dev/shm size, please try running pptr with --disable-dev-shm-usage flag:

const browser = await puppeteer.launch({
  args: ['--disable-dev-shm-usage']
});

Others might be related to the websocket keepalive bug: #1774.

Can someone please check and see if pptr v1.0.0 still fails for you in docker with --disable-dev-shm-usage flag?

Unfortunately I have the same problem, which makes puppeteer hard to use.

Initially it works fine, but later the script starts throwing:

Error: not opened 
at WebSocket.send (/app/node_modules/puppeteer/node_modules/ws/lib/WebSocket.js:344:18) 
at Connection.send (/app/node_modules/puppeteer/lib/Connection.js:72:14) 
at Browser.newPage (/app/node_modules/puppeteer/lib/Browser.js:98:47)...

Puppeteer version 0.13.0, node version 8.3.

It would be really great to have this solved, or at least to apply a workaround.

Thanks.

--disable-dev-shm-usage solved the problem for our docker containers too 👍

Is there some documentation for the implication of this flag? Any drawbacks?

Edit: According to Chromium bug #736452 /tmp will be used instead of /dev/shm shared memory. So a small performance penalty has to be expected whenever /tmp would do reall file io to a hdd/ssd.

@aslushnikov Any news on this bug? This is a huge blocker for us, and many others it seems 😦