я управляю кукловодом на моем сервере nodejs ... идея состоит в том, чтобы открыть страницу, прочитать и отправить капчу пользователю через socket.io, а когда он получает набранное значение капчи от пользователя, чтобы продолжить работу с кукловодом ... здесь все упрощеноверсия моего кода
var captcha = false ;
io.on('connection' , function(socket){
socket.on('start_puppeteer' , function (data) {
io.emit('push_msg' , {text : 'starting puppeteer .... ' });
run(io);
})
socket.on('get_captcha_from_client' , function (data) {
captcha = data.text ;
console.log( 'capthca set : ' + captcha);
})
});
function get_captcha() {
return new Promise(function(resolve , reject ) {
if(captcha === false )
reject(captcha );
else
resolve(captcha);
});
}
async function run(io) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://localhost');
console.log( ' sending captcha to client ' );
io.emit('send_captcha_to_client' , {text : 'captcha text' });
var captcha = await get_captcha();
console.log( ' captcha confirm -> ' + captcha );
browser.close();
}
проблема даже в том случае, если установлена капча, код не будет двигаться вперед, и я не получаю captcha confirm
в консоли
$ node pop.js
sending captcha to client
(node:9356) UnhandledPromiseRejectionWarning: false
(node:9356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
(rejection id: 3)
(node:9356) [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.
capthca set : 1234