chromeless
chromeless copied to clipboard
lambda Unhandled promise rejection ECONNREFUSED
I'm running chromeless against lambda and I intermittently get the following error:
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:9222 (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
my code is very simple:
const { default: Chromeless } = require('chromeless')
new Chromeless({ remote: true })
.goto(url)
.screenshot()
.end()
.then(console.log)
curious if anyone has seen similar.
I believe https://github.com/graphcool/chromeless/issues/187 is similar and there was a fix that had been merged - just not pushed to master atm.
I'm running latest master, published to my org's npm repo. #187 I believe is a different issue.
Hi @pklingem where are you getting that error? In AWS CloudWatch or from Node in a terminal?
@adieuadieu that's from node in the terminal, but the errors show in cloudwatch as well:
START RequestId: 31d738d2-8832-11e7-ae39-bf58b5654704 Version: $LATEST
2017-08-23T18:38:02.445Z 31d738d2-8832-11e7-ae39-bf58b5654704 @serverless-chrome/lambda Spawning headless shell
2017-08-23T18:38:02.446Z 31d738d2-8832-11e7-ae39-bf58b5654704 @serverless-chrome/lambda It took 1ms to spawn chrome.
2017-08-23T18:38:02.446Z 31d738d2-8832-11e7-ae39-bf58b5654704 Invoked with data: cj6pd3v4u000f01qdbw9cktg1 { "debug": false, "waitTimeout": 10000, "remote": true, "implicitWait": true, "scrollBeforeClick": false, "launchChrome": true, "viewport": { "scale": 1 }, "cdp": { "host": "localhost", "port": 9222, "secure": false, "closeTab": true } }
2017-08-23T18:38:02.466Z 31d738d2-8832-11e7-ae39-bf58b5654704 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: read ECONNRESET
2017-08-23T18:38:02.517Z 31d738d2-8832-11e7-ae39-bf58b5654704 Connected to AWS IoT broker
2017-08-23T18:38:02.600Z 31d738d2-8832-11e7-ae39-bf58b5654704 Subscribed to chrome/cj6pd3v4u000f01qdbw9cktg1/request
2017-08-23T18:38:02.875Z 31d738d2-8832-11e7-ae39-bf58b5654704 Message from chrome/cj6pd3v4u000f01qdbw9cktg1/request {"type":"goto","url":"https://html5zombo.com"}
2017-08-23T18:38:02.876Z 31d738d2-8832-11e7-ae39-bf58b5654704 Chrome error { "code": "ECONNRESET", "errno": "ECONNRESET", "syscall": "read" }
2017-08-23T18:38:02.876Z 31d738d2-8832-11e7-ae39-bf58b5654704 (node:1) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
2017-08-23T18:38:32.877Z 31d738d2-8832-11e7-ae39-bf58b5654704 Timing out. No requests received for 30 seconds.
2017-08-23T18:38:32.895Z 31d738d2-8832-11e7-ae39-bf58b5654704 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: read ECONNRESET
END RequestId: 31d738d2-8832-11e7-ae39-bf58b5654704
it happens about every tenth request. It's especially troublesome because it doesn't report the error back to the client correctly, so the Chromeless Proxy eventually times out with:
Chromeless Proxy disconnected due to inactivity (no commands sent for 30 seconds).
I'm running my screenshots in a job and the job retries if it fails, but when the connection refused happens the retry doesn't happen for 30 seconds due to this issue.
I having the exact same problem. I can send it an identical requests in succession and about 1/10th of them will fail.
@adieuadieu do you have any thoughts on where to start looking to track this down? I've been troubleshooting for some time but typescript, async/await are both pretty new to me so that's slowing me down a bit.
this could be a duplicate of: https://github.com/graphcool/chromeless/issues/153
I can confirm that @TravelingTechGuy's timeout solution from #153 improved things for me. Tried to find a more foolproof solution without any luck. It could have something to do with the remote close function which returns a promise, however the two function calls in the body of that function are callback based mqtt functions and neither are awaited. Similarly, end on the lambda side is callback based and isn't awaited.
@pklingem was this issue resolved by v1.3.0?
@adieuadieu I will give it a try and report back.
I have same issue with remote aws, about 4/64 identical requests with fail:
Tested with :
chromless: 1.3.0
CloudWatch logs:
2017-09-12T13:35:58.093Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:9222
2017-09-12T13:35:58.217Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 Connected to AWS IoT broker
2017-09-12T13:35:58.246Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 Subscribed to chrome/cj7hn4ftj001q01p3hdp24alt/request
2017-09-12T13:35:58.460Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 Message from chrome/cj7hn4ftj001q01p3hdp24alt/request
{
"type": "goto",
"url": "https://www.google.com"
}
2017-09-12T13:35:58.461Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 Chrome error
{
"code": "ECONNREFUSED",
"errno": "ECONNREFUSED",
"syscall": "connect",
"address": "127.0.0.1",
"port": 9222
}
2017-09-12T13:35:58.462Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 (node:1) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
2017-09-12T13:36:28.462Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 Timing out. No requests received for 30 seconds.
2017-09-12T13:36:28.496Z 4f201634-97bf-11e7-86ea-a11e547ac9b6 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: connect ECONNREFUSED 127.0.0.1:9222
END RequestId: 4f201634-97bf-11e7-86ea-a11e547ac9b6
I am also having the same problem using chromeless 1.3.0. Just like others it seems that it's about 1 out of every 10 requests or so are failing.
I've done a lot of research on this issue and I'm pretty certain it's related to https://github.com/adieuadieu/serverless-chrome/issues/41. @adieuadieu can you confirm?
@barhoumio @mgolus having the same issue, not always an ECONNREFUSED error, I also get ECONNRESET, websocket timeout, and 504 errors if it helps.
Is there any way to retry or restart the Chromeless proxy after a timeout?
this causes a log of false negative test results. is there a way to retry automatically?
I had the same Timing out. No requests received for 30 seconds
issue and had to rewrite the async function that contains line await chromeless.end()
as a non-async function:
Before:
async function run() {
const chromeless = new Chromeless({remote:...})
...
await chromeless.end()
}
After:
function run() {
const chromeless = new Chromeless({remote:...})
...
chromeless.end().catch(callback).then(callback)
}
The Timing out. No requests received for 30 seconds
errors went away after this change.