pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.31k stars 3.65k forks source link

Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'type') #1633

Closed rbcet closed 1 year ago

rbcet commented 2 years ago

Is there an existing issue for this?

Describe the bug

This is happening when you use MessageMedia with some types of images. For example this one is causing this error.

Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'type') at Object.<anonymous> (https://web.whatsapp.com/bootstrap_qr.bcb4a4e9e67767700178.js:50:357926) at Generator.next (<anonymous>) at t (https://web.whatsapp.com/vendor1~bootstrap_qr.01552bec6677c60ebdd8.js:2:66483) at s (https://web.whatsapp.com/vendor1~bootstrap_qr.01552bec6677c60ebdd8.js:2:66694) at W (https://web.whatsapp.com/bootstrap_qr.bcb4a4e9e67767700178.js:37:130164) at MutationObserver.B (https://web.whatsapp.com/bootstrap_qr.bcb4a4e9e67767700178.js:37:126741) at ExecutionContext._evaluateInternal (/home/pi/whatsapp/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (/home/pi/whatsapp/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Client.sendMessage (/home/pi/whatsapp/node_modules/whatsapp-web.js/src/Client.js:612:28)

base64.txt

meme

Expected behavior

It should not throw any error, because i can send the image from my whatsapp web.

Steps to Reproduce the Bug or Issue

1- MessageMedia.fromFilePath(img); 2- new MessageMedia('image/jpeg', buffer.toString('base64'), '');

and then send it.

Relevant Code

No response

Browser Type

Other (please write in Additional Context)

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Whatsapp web version: 2.2228.14 whatsapp-web.js: latest OS: Raspberry pi OS 64-bit Phone OS: Bluestacks Node: v18.7.0

Additional context

Browser is thorium-special headless. Special fork of chromium.

https://github.com/Alex313031/Thorium-Special

Oliveiiraa commented 2 years ago

Same problem, any news?

rbcet commented 2 years ago

Same problem, any news?

I am ingesting the image with canvas. It works if you send the image that canvas created.