chrome-launcher
chrome-launcher copied to clipboard
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
Component Version Operating system ubuntu16.04 server on remote VPS Node.js v12.8.0 Chrome/Chromium/... chromium-browser chrome-remote-interface 0.27.2
megerr when launching chrome in headlless mode : Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
I'm writing a script node express, when express receive a http request, the script node launch new chrome instance in headless-mode using lib chrome_launcher do some stuff, and kill the istance.
the remote server is a VPS with ubuntu16.04.
to launch the webserver I connect via ssh with VPS: $ node app_ws.js &
If the ssh connection is alive all works fine and node script can launch chrome regularly.
Instead, when I close the terminal and break-down the ssh connection (and the user session terminates) then starts the badly:
in the first request chrome is launched, OK, from the second request onwards script cant launch chrome, the message error is:
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
code snippets
//launch chrome in hadless mode using npm lib chrome_launcher (https://github.com/cyrus-and/chrome-remote-interface) const chrome = await chromeLauncher.launch({ "chromeFlags": [ '--disable-gpu', '--headless' ] }); //Kill Chrome chrome.kill()
chrome.kill() return a promise but dont catch any error
thanks from now for help
Your repro case is a little unclear @sarduk that error sounds like you're killing Chrome too early while there are things being written in the previous case?
The code snippet you have written is killing Chrome as soon as it has launched and is not await
ing the .kill()
promise. Where specifically is this error being thrown? The .launch()
promise rejects with it? It's thrown on the kill as unhandled promise rejection?