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.05k stars 3.58k forks source link

Cannot read properties of undefined (reading 'queryExists') #1313

Closed Eonus21 closed 2 years ago

Eonus21 commented 2 years ago

Is there an existing issue for this?

Describe the bug

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'queryExists') with beta enabled.

Expected behavior

As a user, I expect to receive authendithicated event after code scanning, not an error

Steps to Reproduce the Bug or Issue

  1. Start client with LocalAuthStrategy
  2. Scan QR
  3. Receive such error

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

whatsapp-web v1.16.4-alpha.0

Additional context

No response

Eonus21 commented 2 years ago

Also detected this problem without multidevice enabled

Eonus21 commented 2 years ago

image

This can be used as quick fix, but it can broke getNumberId() function

gg3083 commented 2 years ago

same error, but i uesd getNumberId!

navneetnis1 commented 2 years ago

+1 I am facing same issue.

guicuton commented 2 years ago

If you're on MD you shoudn't use the LegacySessionAuth.

Use LocalAuth or noAuth instead.

gg3083 commented 2 years ago

LocalAuth

I used LocalAuth

guicuton commented 2 years ago

I''ve made some new tests and i'm getting the same issue while using the latest modifications pushed here → https://github.com/pedroslopez/whatsapp-web.js/commit/2718c1328c636d0acecd8cc2910592a693e899b6

Error: Evaluation failed: TypeError: Cannot read property 'queryExists' of undefined at __puppeteer_evaluation_script__:26:69

guicuton commented 2 years ago

I''ve made some new tests and i'm getting the same issue while using the latest modifications pushed here → 2718c13

Error: Evaluation failed: TypeError: Cannot read property 'queryExists' of undefined at __puppeteer_evaluation_script__:26:69

This here working on WWEBVERSION: 2.2208.7 After update to this branch, remember to delete the .wwebjs_auth before to start your app.

Eonus21 commented 2 years ago

I''ve made some new tests and i'm getting the same issue while using the latest modifications pushed here → 2718c13 Error: Evaluation failed: TypeError: Cannot read property 'queryExists' of undefined at __puppeteer_evaluation_script__:26:69

This here working on WWEBVERSION: 2.2208.7 After update to this branch, remember to delete the .wwebjs_auth before to start your app.

So it starts working after rescan?

Eonus21 commented 2 years ago

Because I start to receive new error on message sending https://github.com/pedroslopez/whatsapp-web.js/issues/1317

dardar1129 commented 2 years ago

image

This can be used as quick fix, but it can broke getNumberId() function

After implementing this I am getting this error (node:9544) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'queryExists')

sciapuscio commented 2 years ago

Same issue... is not working

jbmchd commented 2 years ago

same issue

janke184 commented 2 years ago

Same here using LocalAuth :(

jonasschen commented 2 years ago

Same here. Using multidevice branch

sidikhanrei commented 2 years ago

Try my temporary fix. It will use old queryExists function if client not updated.

Client.js Line 944

async getNumberId(number) {
        if (!number.endsWith('@c.us')) {
            number += '@c.us';
        }
        return await this.pupPage.evaluate(async number => {
            try {

                const result = await window.Store.QueryExist(number);
                if (!result || result.wid === undefined) return null;
                return result.wid;

            } catch(err){

                let result = await window.Store.Wap.queryExist(number);
                if (result.jid === undefined)
                    throw 'The number provided is not a registered whatsapp user';
                return result.jid;
            }
        }, number);
    }
sciapuscio commented 2 years ago

Worked for me... ! =D temporary fix works well. Thanks @sidikhanrei

sciapuscio commented 2 years ago

It connects fine but then it doesn't send the messages. There is no log record.

sidikhanrei commented 2 years ago

use this release version https://www.npmjs.com/package/whatsapp-web.js/v/1.16.4-alpha.0 and replace the Client with temporary fix

sciapuscio commented 2 years ago

Using 1.16.4-alpha.0 I closed and opened the console and again "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'query Exists')" =(... Something bad is happening here.

Another symptom, the session folder is always left empty.

cristovammartins commented 2 years ago

Sessão não estava salvando tbm

sciapuscio commented 2 years ago

sometimes connect. When it does it appears to work but in reality the session folder is empty and the messages don't come out.

CHECKED

elhumbertoz commented 2 years ago

I have the same error.!

kikemarto commented 2 years ago

I have devices with the problem and another devices without it, it's very strange.

sciapuscio commented 2 years ago

@kikemarto Me too... two services on the same OS... one is working I WILL TRY TO NEVER CLOSE IT an the other service is just DEAD

kikemarto commented 2 years ago

The services that works I can restart without problems and works continue.

sciapuscio commented 2 years ago

spooky 🥴🥴

CValeron commented 2 years ago

same issue :(

dardar1129 commented 2 years ago

on restarting the service, it sends the message for the first time. and then shows the error.

(node:25012) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'queryExists')

This is something strange, please fix this asap. There is no stable version too, I am getting errors on 4 previous versions.

josuelmm commented 2 years ago

Same error but Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'cast')

(node:34196) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'cast') at m._basicSend (https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:65:676297) at m.phoneTimedOut (https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:65:675603) at m.s (https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:70:10060) at https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:70:9056 at t.ShiftTimer._run (https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:5:340486) at t.ShiftTimer.forceRunNow (https://web.whatsapp.com/bootstrap_qr.79aba964bea38dbcc501.js:5:340827) at puppeteer_evaluation_script:2:60 at ExecutionContext._evaluateInternal (D:\xampp\htdocs\WhatsApp\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async ExecutionContext.evaluate (D:\xampp\htdocs\WhatsApp\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16) at async Client.resetState (D:\xampp\htdocs\WhatsApp\node_modules\whatsapp-web.js\src\Client.js:924:9) (Use node --trace-warnings ... to show where the warning was created) (node:34196) 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:34196) [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.

sciapuscio commented 2 years ago

We need you @pedroslopez !!!! =(

pedroslopez commented 2 years ago

This issue was happening because WhatsApp Web was sometimes serving up v2.2206.9 and then updating it to v2.2208.7 in some cases. Now that 2.2208.7 seems to be the only version getting served, I released v1.16.4 of the library to address this. Please update and this shouldn't be happening anymore.

dardar1129 commented 2 years ago

This issue was happening because WhatsApp Web was sometimes serving up v2.2206.9 and then updating it to v2.2208.7 in some cases. Now that 2.2208.7 seems to be the only version getting served, I released v1.16.4 of the library to address this. Please update and this shouldn't be happening anymore.

Hey Thanks a lot @pedroslopez I updated to v1.16.4 and it seems to work perfectly as of now.

Eonus21 commented 2 years ago

Fixed in v1.16.4

herduin commented 2 years ago

I have this problem in v1.16.4 in Non-MD session. Any idea?

whizydev commented 2 years ago

Updated to latest version. This error happens to me since today. Before it worked well.

priti0802 commented 2 years ago

Updated to latest version. This error happens to me since today. Before it worked well.

SAME I AM NOT ABLE TO FIX THE ISSUES

[Cannot read properties of undefined (reading 'queryExists')..

PLZ HELP FOR THE SAME

ghost commented 1 year ago

erro: Cannot read properties of undefined (reading 'queryExists')

hey guys. it worked for me to delete the '.wwebjs_auth' folder and reconnect generating a new QRCODE.

willkuerlich commented 1 year ago

erro: Cannot read properties of undefined (reading 'queryExists')

hey guys. it worked for me to delete the '.wwebjs_auth' folder and reconnect generating a new QRCODE.

I am getting the same error, from this day on. Bot has been working for several weeks without any issues. After authenticating with qr via localAuth strategy, this error is thrown. Even with deleting the ".wwebjs_auth" directory in advance.

\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'queryExists')
    at __puppeteer_evaluation_script__:25:69
at ExecutionContext._evaluateInternal ...

Tried with whatsapp-web version 1.19.3 and 1.19.1

Is the dependency on puppeteer version 13.0.0 correct?

jauharitontowi commented 1 year ago

i have the same error

willkuerlich commented 1 year ago

Maybe Whatsapp changed the DOM structure of their html page?

willkuerlich commented 1 year ago

@pedroslopez Would you mind to have a look?

In my case it is currently really annoying to run my dev environment, since every app restart means now to have to scan the qr code every time :*(

Update: https://github.com/tofers/whatsapp-web.js/pull/2 Fixes it! 🚀🚀🚀

DiegoDelBianco commented 1 year ago

@pedroslopez Would you mind to have a look?

In my case it is currently really annoying to run my dev environment, since every app restart means now to have to scan the qr code every time :*(

Update: tofers#2 Fixes it! rocketrocketrocket

Great!

I replace the line 28 of file src/util/Injected.js to: window.Store.QueryExist = window.mR.findModule('queryExist')[0].queryWidExists;

And work to me now, thanks

borjaom23 commented 1 year ago

Using 1.19.5 Same issue... is not working We need you @pedroslopez !!