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.19k stars 3.62k forks source link

I am getting error when giving node app.js #2910

Closed jorgelds96 closed 5 months ago

jorgelds96 commented 5 months ago

Is there an existing issue for this?

Describe the bug

The error occurs when running the script inside the cache folder.

node_modules\.pnpm\whatsapp-web.js@1.23.0\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34
const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1]

I put it to insert a fixed value 2.2206.9 and it didn't have the same error, but scanning the qr code it didn't do anything else and when I try to call the end point it gives the following error

node_modules\.pnpm\puppeteer@13.7.0\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 'getChats')
    at __puppeteer_evaluation_script__:2:40
    at ExecutionContext._evaluateInternal (C:\Dev\Rpa\APi Whatsapp\api_whatsapp\node_modules\.pnpm\puppeteer@13.7.0\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 (C:\Dev\Rpa\APi Whatsapp\api_whatsapp\node_modules\.pnpm\puppeteer@13.7.0\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.getChats (C:\Dev\Rpa\APi Whatsapp\api_whatsapp\node_modules\.pnpm\whatsapp-web.js@1.23.0\node_modules\whatsapp-web.js\src\Client.js:927:21)
    at async C:\Dev\Rpa\APi Whatsapp\api_whatsapp\app.js:284:19 

Expected behavior

N/A

Steps to Reproduce the Bug or Issue

N/A

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

LocalWebCache.js

async persist(indexHtml) { // extract version from index (e.g. manifest-2.2206.9.json -> 2.2206.9) const version = indexHtml.match(/manifest-([\d\.]+).json/)[1]; if(!version) return;

    const filePath = path.join(this.path, `${version}.html`);
    fs.mkdirSync(this.path, { recursive: true });
    fs.writeFileSync(filePath, indexHtml);
}

ExecutionContext.js
 const { exceptionDetails, result: remoteObject } = await callFunctionOnPromise.catch(rewriteError);
    if (exceptionDetails)
        throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));

Additional context

No response

alechkos commented 5 months ago

2789