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.04k stars 3.57k forks source link

client.getChats() is not working #3198

Closed vikramsingh-vicky closed 1 month ago

vikramsingh-vicky commented 1 month ago

Is there an existing issue for this?

Describe the bug

It is showing Cannot read properties of null.

Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'update') at window.WWebJS.getChatModel (pptr://puppeteer_evaluation_script:396:46) at pptr://puppeteer_evaluation_script:424:62 at Array.map () at window.WWebJS.getChats (pptr://puppeteer_evaluation_script:424:36) at pptr://puppeteer_evaluation_script:2:40 at ExecutionContext._ExecutionContext_evaluate (D:\Vicky_Projects\WA_Controller_Based\backend\node_modules\puppeteer-core\lib\cjs\puppeteer\common\ExecutionContext.js:229:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (D:\Vicky_Projects\WA_Controller_Based\backend\node_modules\puppeteer-core\lib\cjs\puppeteer\common\ExecutionContext.js:107:16) at async Client.getChats (D:\Vicky_Projects\WA_Controller_Based\backend\node_modules\whatsapp-web.js\src\Client.js:927:21) at async Socket. (D:\Vicky_Projects\WA_Controller_Based\backend\middleWare\whatsappSession.js:199:31)

Expected behavior

It should return the chats of the client in json format

Steps to Reproduce the Bug or Issue

simple run client.getChats()

Relevant Code

const chats = await client.getChats(); console.log(chats)

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows Phone: android Whatsapp-web.js version: 1.24.0 Node.js version: v20.12.2

Additional context

No response

plasusu commented 1 month ago

https://github.com/wppconnect-team/wa-js

This repository is updating more promptly. The Bug you mentioned has fixed 3 days ago.

vikramsingh-vicky commented 1 month ago

https://github.com/wppconnect-team/wa-js

This repository is updating more promptly. The Bug you mentioned has fixed 3 days ago.

Can you please guide me through it. I'm unable to find where you are pointing.

vikramsingh-vicky commented 1 month ago

I got the solution, changing the src.injected.js FROM: window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata; window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById; TO: window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].GroupMetadata; // window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;