prerender: Unrecoverable error with headless chrome
prerender version: 5.0.1 chrome version: Started Chrome: HeadlessChrome/62.0.3202.94
2017-11-16T16:41:14.452Z getting http://peka2.tv/muzmurkin
2017-11-16T16:41:16.589Z unable to evaluate javascript on the page
2017-11-16T16:41:16.589Z Chrome connection closed during request
2017-11-16T16:41:16.590Z got 504 in 2138ms for http://peka2.tv/muzmurkin
2017-11-16T16:41:16.590Z error closing Chrome tab Error: not opened
at WebSocket.send (/root/chat/node_modules/chrome-remote-interface/node_modules/ws/lib/WebSocket.js:355:18)
at Chrome.enqueueCommand (/root/chat/node_modules/chrome-remote-interface/lib/chrome.js:124:16)
at /root/chat/node_modules/chrome-remote-interface/lib/chrome.js:86:28
at new Promise (<anonymous>)
at Chrome.send (/root/chat/node_modules/chrome-remote-interface/lib/chrome.js:85:16)
at Object.handler [as closeTarget] (/root/chat/node_modules/chrome-remote-interface/lib/api.js:32:23)
at Promise (/root/chat/node_modules/prerender/lib/browsers/chrome.js:146:22)
at new Promise (<anonymous>)
at Object.chrome.closeTab (/root/chat/node_modules/prerender/lib/browsers/chrome.js:144:9)
at Object.server.finish (/root/chat/node_modules/prerender/lib/server.js:239:16)
2017-11-16T16:41:16.686Z getting http://peka2.tv/muzmurkin
{ Error: connect ECONNREFUSED 127.0.0.1:9222
at Object._errnoException (util.js:1031:13)
at _exceptionWithHostPort (util.js:1052:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9222 }
2017-11-16T16:41:16.696Z got 504 in 10ms for http://peka2.tv/muzmurkin
2017-11-16T16:41:17.060Z getting http://peka2.tv/muzmurkin
{ Error: connect ECONNREFUSED 127.0.0.1:9222
at Object._errnoException (util.js:1031:13)
at _exceptionWithHostPort (util.js:1052:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9222 }
2017-11-16T16:41:17.065Z got 504 in 5ms for http://peka2.tv/muzmurkin
and everything further dies in 504 and ECONNREFUSED 127.0.0.1:9222 until manual service restart service code
var prerender = require('prerender');
var memoryCache = require('./cache');
var server = prerender({
chromeFlags: [ '--no-sandbox', '--headless', '--disable-gpu', '--remote-debugging-port=9222', '--hide-scrollbars' ],
workers: 4,
});
server.use(prerender.sendPrerenderHeader());
server.use(prerender.removeScriptTags());
// handle 404
server.use(prerender.httpHeaders());
server.use(memoryCache);
server.start();
no-sandbox used due to running via root inside docker container
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 42 (19 by maintainers)
I just pushed v5.2.0 of the Prerender server to have Prerender restart Chrome every 10 minutes if there are no requests in flight and every hour if there are requests in flight for the whole hour.
At the hour mark, all new requests will wait until in-flight requests have finished and until the server is restarted before continuing. Again, that’s only if there’s a browser request in flight for the full hour. The waiting is to prevent a 504 for any URLs by letting them take a little longer to load by waiting.
This bandaid isn’t ideal but it should be a short term fix and shouldn’t cause any issues.
Please let me know if you try this out and if it improves the stability of the Prerender server.
Hm, one more issue
and so one. I dont know why, in container i see a lot of chrome processes
looks like they are hanged. Test request with
?_escaped_fragment_=1
returns 504. Everything is fine after container restart.Aw bummer. We have some health checks on our infrastructure that detect any issues and pulls those servers from the load balancer. We also have other checks to restart Chrome every so often. You might want to try doing something like that too.
It’ll be hard to look into this without a reproducible test case, and from what you sent over it looks like Prerender is losing the connection to Chrome somehow. I’ll try to look into some ways to improve general reliability of detecting an issue with the connection.