whatsapp-api-tutorial icon indicating copy to clipboard operation
whatsapp-api-tutorial copied to clipboard

(node:21) UnhandledPromiseRejectionWarning: (node:21) [DEP0018] DeprecationWarning:

Open empueko opened this issue 4 years ago • 9 comments

(node:21) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

(node:21) [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.

ini kenapa yah , sebelumnya semua berjalan normal mohon di bantu

empueko avatar Aug 25 '21 01:08 empueko

I have the same error, it is a new installation, in another that I have, in the same vps provider, but in another account, it works perfectly.

gmlmaino avatar Aug 31 '21 15:08 gmlmaino

Pastikan sudah menggunakan versi whatsapp-web.js terbaru dan Node.js v14 atau yang lebih baru.

ngekoding avatar Sep 01 '21 00:09 ngekoding

Ini bukan versi simpul, itu membuat kesalahan yang sama dijelaskan dan versi simpul adalah root @ nodejs-ubuntu-s--1gb-AMD-sfo3-01: ~ # node -v v14.17.6

It is not the node version, it makes the same error described and the node version is root @ nodejs-ubuntu-s--1gb-amd-sfo3-01: ~ # node -v v14.17.6

gmlmaino avatar Sep 01 '21 03:09 gmlmaino

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/opt/whatsapp-api/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
at Interface.<anonymous> (/opt/whatsapp-api/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
at Interface.emit (events.js:412:35)
at Interface.close (readline.js:451:8)
at Socket.onend (readline.js:224:10)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

(Use node --trace-warnings ... to show where the warning was created) (node:1057) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:1057) [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.

gmlmaino avatar Sep 01 '21 03:09 gmlmaino

Try to add catch for initialize, see example below:

const { Client } = require("whatsapp-web.js");
const client = new Client();
// .....
// your another code
// .....
client.initialize().catch(_ => _);

ngekoding avatar Sep 01 '21 04:09 ngekoding

Captura de pantalla

gmlmaino avatar Sep 01 '21 04:09 gmlmaino

const { Client } = require('whatsapp-web.js');

const client = new Client();

client.on('qr', (qr) => { // Generate and scan this code with your phone console.log('QR RECEIVED', qr); });

client.on('ready', () => { console.log('Client is ready!'); });

client.on('message', msg => { if (msg.body == '!ping') { msg.reply('pong'); } });

client.initialize();

gmlmaino avatar Sep 01 '21 04:09 gmlmaino

it seems that is when you try to open the chromiun

gmlmaino avatar Sep 01 '21 04:09 gmlmaino

That is a different issue, please read the error message for detail. You need to install another library to make Puppeteer running on Ubuntu.

ngekoding avatar Sep 01 '21 06:09 ngekoding