whatsapp-web.js: WhatsApp does not work on v2.3XXX

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Three days ago I started to receive the following error on account start: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'push')\n at fillModuleArray (eval at <anonymous> (:2:5), <anonymous>:6:74)\n at moduleRaid (eval at <anonymous> (:2:5), <anonymous>:15:3)\n at puppeteer_evaluation_script:4:17

Expected behavior

As a user, I expect to be logged in and able to send messages. But I am seeing desribed error.

Steps to Reproduce the Bug or Issue

  1. Run basic example
  2. On some accounts it is not logged in

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

OS: Linux and Windows whatsapp-web.js version: latest, installed directly from GitHub (https://github.com/pedroslopez/whatsapp-web.js/commit/ef2f725bce1bd1afd8491f9de0cd2ed06a6febc3) WhatsApp Web version: 2.3000.1011643235 Node.js version: v18.19.0

Additional context

  1. It is possible that the problem is related to new version (https://github.com/pedroslopez/whatsapp-web.js/commit/17c75ccf5f5a5103e80f8eaa08e641f065de4fea new 2.2408.1 wweb version)
  2. I found where error is thrown, it is inside moduleraid library (Related issue - https://github.com/pedroslopez/moduleRaid/issues/5)
  3. Other related issues - https://github.com/pedroslopez/whatsapp-web.js/issues/2785

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Reactions: 8
  • Comments: 155

Commits related to this issue

Most upvoted comments

const wwebVersion = '2.2412.54';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    // locking the wweb version
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Relevant WWeb versions can be found here

Screenshot 2024-03-08 175934

I use LocalAuth every time I want to reload the cache, the error message always appears, please help me

SOLVED Use :

webVersionCache: { type: ‘remote’, remotePath: ‘https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html’, }

Please don’t close this issue because I took the time to find the specific place where this error occurs. I’ve searched through existing issues and not a single potential duplicate mentions a solution. My previous issue was closed without any clarifications about reasons for that.

Apparently they are moving from Webpack to some other framework called Comet. In order to reproduce the problem and get the 2.3000 version that is based on Comet you need to add a cookie: wa_build=c You can add it manually in DevTools and refresh the page. Hopefully this will help someone to figure out how to find the modules under Comet. As a temporary workaround for users that are already getting the Comet version, remove this cookie or change it to wa_build=w and refresh the page.

Is there any update or solution related to this issue?

Solved by putting the line below in Client.js: Captura de Tela 2024-03-25 às 13 22 51

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d\.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

apparently WhatsApp has finally switched to Comet. Deleting cookies doesn’t help, all accounts have this error

Hi, I found a temporary solution .

The error

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'push')
    at fillModuleArray (eval at <anonymous> (:2:5), <anonymous>:6:74)
    at moduleRaid (eval at <anonymous> (:2:5), <anonymous>:15:3)
    at __puppeteer_evaluation_script__:4:17
    at ExecutionContext._evaluateInternal (/.../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 (/.../node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Client.initialize (/.../node_modules/whatsapp-web.js/src/Client.js:340:3)

at src/Client.js #339

await page.evaluate(ExposeStore, moduleRaid.toString());

.

The source code of WA is different when the browser is reloaded an there is a session. The new version 2.3.x.x set a cookie wa_build and these make the source code changes. ( @micmil1977 said it )

The solution is remove the cookie always. If the cookie was present when the puppeteer was loaded the page, delete cookie and reload it

The code:

await page.deleteCookie({name:'wa_build', domain:'.web.whatsapp.com', path:'/'});

I put it in all places i can because i don’t know when the cookie is established.

Can you explain in a little more detail?

@pedroslopez We need your help, the problem persists

Hey everyone! I haven’t noticed that the update already started rolling out. I’ll be updating moduleRaid to support the new version, it is very simple!

Any updates? Still receiving this error. After clearing session, reconnection of account passes couple of hours and error showing.

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Relevant wweb versions can be found here

this worked for me

Código completo aqui nesta PR abaixo, mas precisa de compilar o moduleRaid e instalar pelo .tgz dele. PR 2882

for me this worked

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

If anyone encounter error while trying to send media using new release

Just change this line

const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);

Into this

const mediaObject = window.Store.MediaObject(mediaData.filehash);

In src/util/Utils.js on line 323, and give a try

Another approach and to keep legacy compatibility, is to change the line which export mediaobject in src/util/Injected/store.js

from window.Store.MediaObject = require('WAWebMediaStorage').getOrCreateMediaObject;

To

window.Store.MediaObject = require('WAWebMediaStorage');

In this way we do not need to change the Utils.js file because is common between legacy and version, and we just change store exposing for new one where the real issue occurs

También el mismo problema.

A mi me funciono las soluciones de

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Lo unico es que tuve que borrar las sessiones ya existentes y hacer login con QR desde el principio

Lo mismo,a mi también me funcionó esto,solo borre las sesiones

También el mismo problema.

A mi me funciono las soluciones de

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

Lo unico es que tuve que borrar las sessiones ya existentes y hacer login con QR desde el principio

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

the solution is here , it works for me

const wwebVersion = '2.2407.3';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

same here

unhandledRejection signal received. 
 TypeError: Cannot read properties of null (reading '1')
 TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at C:\iconatus\scripts-iconatus\bot-whatsapp-ai-send\node_modules\whatsapp-web.js\src\Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

After this Whatsapp sent a message saying that I was using an unofficial application and closed my WhatsApp, it did not block the line but it did close the account.

Hello,

const SESSION_FILE_PATH = ‘./session.json’;

let sessionData;

if (fs.existsSync(SESSION_FILE_PATH)) { sessionData = require(SESSION_FILE_PATH); }

const client = new Client({ puppeteer: { executablePath: ‘C:\Program Files\Google\Chrome\Application\chrome.exe’, args: [‘–no-sandbox’] }, authStrategy: new LocalAuth({ clientId: “Client-one” }), webVersionCache: { type: ‘remote’, remotePath: ‘https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html’ } });

client.on(‘qr’, (qr) => { qrcode.generate(qr, { small: true }); });

client.on(‘authenticated’, (session) => { console.log(‘Conexión exitosa’); sessionData = session; if (sessionData) { fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), (err) => { if (err) { console.error(err); } }); } });

use it like this it works perfect, send messages, receive, send files, and save the session

It didn’t work here, I still get the error

usr/src/app/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34 const version = indexHtml.match(/manifest-([\d.]+).json/)[1]; ^

TypeError: Cannot read properties of null (reading ‘1’) at LocalWebCache.persist (/usr/src/app/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69) at /usr/src/app/node_modules/whatsapp-web.js/src/Client.js:744:36 at processTicksAndRejections (node:internal/process/task_queues:96:5)

in V2.3, when trying to send a message with error ‘window.Store.MsgKey is not a constructor’ any idea how to solve it? have you succeeded sending text message in V2.3?

any updates on this?

Hi, I found a temporary solution . The error

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'push')
    at fillModuleArray (eval at <anonymous> (:2:5), <anonymous>:6:74)
    at moduleRaid (eval at <anonymous> (:2:5), <anonymous>:15:3)
    at __puppeteer_evaluation_script__:4:17
    at ExecutionContext._evaluateInternal (/.../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 (/.../node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Client.initialize (/.../node_modules/whatsapp-web.js/src/Client.js:340:3)

at src/Client.js #339

await page.evaluate(ExposeStore, moduleRaid.toString());

. The source code of WA is different when the browser is reloaded an there is a session. The new version 2.3.x.x set a cookie wa_build and these make the source code changes. ( @micmil1977 said it ) The solution is remove the cookie always. If the cookie was present when the puppeteer was loaded the page, delete cookie and reload it The code:

await page.deleteCookie({name:'wa_build', domain:'.web.whatsapp.com', path:'/'});

I put it in all places i can because i don’t know when the cookie is established.

Can you explain in a little more detail? @pedroslopez We need your help, the problem persists

The cookie make the source of the web changes: the-cookie The new source code with cookie with-cookie The old source code was loaded if the cookie is not present without-cookie I notice the cookie was setted after the auth is ready so i put the code:

class LocalAuth extends BaseAuthStrategy {
    ...
    async afterAuthReady() {
        const page = this.client.pupPage;
        await page.deleteCookie({name:'wa_build', domain:'.web.whatsapp.com', path:'/'});
    }
    ...
}

If the cookie is present in the line 339 on src/Client.js image I suggest execute the code and reload the Client.

await page.deleteCookie({name:'wa_build', domain:'.web.whatsapp.com', path:'/'});

Psdt: I used the commit 1.23.1-alpha.5

I do not suggest this method, as maybe whatsapp can detect that same client is going in a short way from old to new version and vice versa and this may lead to some bad classifications,

I prefer to work on supporting new version instead of keep running away from it

Its correct. For that I said is a temporary solution while we work on supporting 2.3xx completely.

hi guys dont waste time, this is the solution that worked for me: #2816

But how can i implement it? It’s already in the npm latest version?

i went line by line… its not on the latest version yet

Funcionou pra mim fazendo: Alterando em: webCache/LocalWebCache.js a linha 34; De: const version = indexHtml.match(/manifest-([\d.]+).json/)[1]; Para: const version = indexHtml.match(/manifest.json/)[1]; Depois fui em moduleRaid na lib node_modules/@pedroslopez/moduleraid e fiz a modificação do Devaec

Testei a sua solução e a conexão é feita, mas outros erros começaram a aparecer.

Quando envio a mensagem para o Whatsapp: ERROR: Error handling whatsapp message: Err: [object Object] Ou quando tento enviar uma mensagem: Err: Error: Protocol error (Runtime.callFunctionOn): Session closed.

webpack-exodus branch Just release a fix

the project moduleRaid was updated, however still necessary to update file src/util/Intected.js

const isComet = parseInt(window.Debug?.VERSION?.split(".")?.[1]) >= 3000;

console.warn('COMET package version:%s', window.Debug?.VERSION)

eval('var moduleRaid = ' + moduleRaidStr);
// eslint-disable-next-line no-undef
window.mR = moduleRaid();
//window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
window.Store = {};

if (isComet) {
    window.Store.Chat = window.mR.findModule('Chat')[1].Chat;
} else {
    window.Store.Chat = window.mR.findModule(m => m.default && m.default.Chat)[0].default.Chat;
}

window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
window.Store.BlockContact = window.mR.findModule('blockContact')[0];

if (isComet) {
    window.Store.Call = window.mR.findModule('Call')[0].Call;
} else {
    window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
}

window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;

if (isComet) {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].GroupMetadata;
} else {
    window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
}

if (isComet) {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
} else {
    window.Store.GroupMetadata.queryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
}

if (isComet) {
    window.Store.Contact = window.mR.findModule('Contact')[0].Contact;
}

window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
window.Store.ContactCollection = window.mR.findModule('ContactCollection')[0].ContactCollection;
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];

if (isComet) {
    window.Store.MsgKey = window.mR.findModule('fromString')[0];
} else {
    window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
}

if (isComet) {
    window.Store.Msg = window.mR.findModule('Msg')[1].Msg;
}

if (isComet) {
    window.Store.OpaqueData = window.mR.findModule('createFromData')[0];
} else {
    window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
}

window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
window.Store.SendClear = window.mR.findModule('sendClear')[0];
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
window.Store.BusinessProfileCollection = window.mR.findModule('BusinessProfileCollection')[0].BusinessProfileCollection;

if (isComet) {
    window.Store.UploadUtils = window.mR.findModule('encryptAndUpload')[0].encryptAndUpload;
} else {
    window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
}

if (isComet) {
    try {
        window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
    } catch (e) {
        try {
            window.Store.UserConstructor = window.mR.findModule('isServer')[0].isServer;
        } catch (e2) {
            try {
                window.Store.UserConstructor = window.mR.findModule('isUser')[0].isUser;
            } catch (e3) {
                let checkType = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser))[0].default
                if (checkType.isServer) {
                    window.Store.UserConstructor = checkType.isServer
                } else if (checkType.isUser) {
                    window.Store.UserConstructor = checkType.isUser
                }
            }
        }
    }
} else {
    window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
}

window.Store.Validators = window.mR.findModule('findLinks')[0];

Can you explain a little more? Using this file version we can use on 2.3x?

const client = new Client({

I see, but in our case, we are using RemoteAuth, and this would hardcode the same version (2.2407.3) for every client that creates a whatsapp session, am I correct? EDIT: fix typo

Hey folks, we are using RemoteAuth given that we have several sessions being managed by the same app. has anybody been able to find a workaround for this problem? I has started happening today and it cannot start a sesion:

Session does not exist. Creating userDataDir...
extractRemoteSession completed.
beforeBrowserInitialized completed.
/home/ec2-user/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^
TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (/home/ec2-user/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at /home/ec2-user/whatsapp-web.js/src/Client.js:775:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.18.2

@denikaryadi what file is this? @noobsmatr619 what folder? @MoudiZd I didn’t understand your solution or workaround, I’m just trying to start whatsapp without issues.

Read the closed issue mentioned in my comment it contains the explanation of the issue and the title of some solutions and workarounds, but you can find the details about these solutions and workaround within pull requests and issues comments

Read every pull request and every issue , because the solution in current time is not included in one place as it is not based on one reason

If you want, you can join discord server, it has too many conversation about all new issues and about current status of the service

https://discord.gg/H7DqQs4

Hello,

const SESSION_FILE_PATH = ‘./session.json’;

let sessionData;

if (fs.existsSync(SESSION_FILE_PATH)) { sessionData = require(SESSION_FILE_PATH); }

const client = new Client({ puppeteer: { executablePath: ‘C:\Program Files\Google\Chrome\Application\chrome.exe’, args: [‘–no-sandbox’] }, authStrategy: new LocalAuth({ clientId: “Client-one” }), webVersionCache: { type: ‘remote’, remotePath: ‘https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html’ } });

client.on(‘qr’, (qr) => { qrcode.generate(qr, { small: true }); });

client.on(‘authenticated’, (session) => { console.log(‘Conexión exitosa’); sessionData = session; if (sessionData) { fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), (err) => { if (err) { console.error(err); } }); } });

use it like this it works perfect, send messages, receive, send files, and save the session

Hello after use this code with const client = new Client({ puppeteer: { headless: false }, authStrategy: new LocalAuth({ clientId: “Client-one” }), webVersionCache: { type: ‘remote’, remotePath: ‘https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html’ } }); this app, work for me.

316576037-c3998553-95dc-425a-98ad-ff14920c5fca

This worked for me by modifying the Client.js file

Olá,

const SESSION_FILE_PATH = ‘./session.json’;

deixe sessionData;

if (fs.existsSync(SESSION_FILE_PATH)) { sessionData = require(SESSION_FILE_PATH); }

cliente const = novo cliente ({ puppeteer: { executablePath: ‘C:\Program Files\Google\Chrome\Application\chrome.exe’, args: [‘–no-sandbox’] }, authStrategy: new LocalAuth({ clientId : “Client-one” }), webVersionCache: { type: ‘remote’, remotePath: ’ https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html ’ } });

client.on(‘qr’, (qr) => { qrcode.generate(qr, { small: true }); });

client.on(‘authenticated’, (session) => { console.log(‘Conexión exitosa’); sessionData = session; if (sessionData) { fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), (err) = > { if (erro) { console.error(erro); } }); } });

use assim funciona perfeitamente, envie mensagens, receba, envie arquivos e salve a sessão

Thank you very much! It took a while, but it worked without having to scan the QRcode again. In my case I am using PM2 to restart the application.

await page.deleteCookie({name:‘wa_build’,domain:‘.web.whatsapp.com’,path:‘/’});

Solved by putting the line below in Client.js: Captura de Tela 2024-03-25 às 13 22 51

Funcionou para mim.

Screenshot 2024-03-08 175934

I use LocalAuth every time I want to reload the cache, the error message always appears, please help me

How do you get wweb version 2.3000? Last version seems to be 2.2408