question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Crash of process exit(1) [puppeteer-extra-plugin-recaptcha]

See original GitHub issue

When using the “puppeteer-extra-plugin-recaptcha” module, I often encounter the error:

exit(1)
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 89.108.117.181:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketErrorListener (_http_client.js:469:9)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '89.108.117.181',
  port: 80
}

It is most likely related to network problems.

We check the ip address and get the culprit:

host 89.108.117.181
181.117.108.89.in-addr.arpa domain name pointer 2captcha.com.

My packages in package.json:

{
	"dependencies": {
		"cheerio": "^1.0.0-rc.3",
		"node-telegram-bot-api": "^0.50.0",
		"puppeteer": "^5.5.0",
		"puppeteer-extra": "^3.1.15",
		"puppeteer-extra-plugin-adblocker": "^2.11.9",
		"puppeteer-extra-plugin-recaptcha": "^3.3.0",
		"puppeteer-extra-plugin-stealth": "^2.6.5",
		"request": "^2.88.2",
		"simple-proxy-agent": "^1.1.0",
		"tough-cookie-file-store": "^2.0.2"
	}
}

Calling packages in index.js:

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); 
puppeteer.use(StealthPlugin());

const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha'); 
puppeteer.use(
	RecaptchaPlugin({
		provider: {
			id: '2captcha',
			token: '<2captcha key>',
		},
		visualFeedback: true,
	})
);

Search by code in the project where the entry exit(1) was encountered. Screenshot_20201213_011630

All functions in the code are wrapped in try/catch. Process termination exit(1) - calls the package from dependencies. Any ideas on how to fix the problem?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ergcodecommented, Feb 3, 2021

@ergcode any update on this, is this still happening? 😃 I apologize for the long wait.

Now my script periodically saves its state in JSON. And after the fall, it restores its state from this file. Therefore, the problem is not so critical.

But so far I have not been able to accurately track the error.

According to statistics:

  • passed ~ 14000 captchas,
  • 127 restarts after crashing in “pm2 monit”.

package.json

	"dependencies": {
		"puppeteer": "^5.5.0",
		"puppeteer-extra": "^3.1.16",
		"puppeteer-extra-plugin-recaptcha": "^3.3.2",
		"puppeteer-extra-plugin-stealth": "^2.6.7"
	},

I’ll try to change the code from code.js

		try {
			await page.waitForSelector(`#g-recaptcha`, { timeout: 10000 });
			await page.solveRecaptchas();
			await page.click(`#g-recaptcha`);
		} catch (error) { console.error(error); }

to this code code.js

		try {
			process.on(`uncaughtException`, (error) => console.log(error));
			await page.waitForSelector(`#g-recaptcha`, { timeout: 10000 });
			await page.solveRecaptchas().catch((error) => console.error(error));
			await page.click(`#g-recaptcha`);
		} catch (error) { console.error(error); }

Maybe I’ll get a little more data.

0reactions
berstendcommented, Feb 7, 2021

@ergcode great to hear 😃 Closing for now, I will keep this in mind when I do a planned rewrite of the recaptcha plugin.

PS: I added Github Sponsors links a few days ago 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How to handle Puppeteer "Error: Page crashed!"
I close all pages once done, so there is only 1 page open at a time. And the droplet does only this process....
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
If it's greater than that, it indicates that an error occurred; 1 is a common exit code for failures here. Another option is...
Read more >
How to Exit a Process in Node.js: process.exit() Method
Learn how to terminate a Node.js application in the best possible way. We will explain how to do this with the process.exit() function...
Read more >
The Death of a Node.js Process - Thomas Hunter II
Manual process exit, process.exit(1). Uncaught exception, throw new Error(). Unhandled promise rejection, Promise.reject(). Ignored error ...
Read more >
Node.js process.exit() Method - GeeksforGeeks
Case 1: Without using process.exit() method: ... that automatically stops the NodeJS program when there is some problem with the code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found