Open Eonus opened 4 months ago
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 new source code with cookie
The old source code was loaded if the cookie is not present
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
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.
@MoudiZd I'm using 2.300 so it's invalid for me when will a solution come for 2.3
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?
Same error here... any workaround pls?
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
Worked for me.
That works, but forces me to recapture the QR, and I can't... any solution without forcing to recapture QR? thanks.
Solved by putting the line below in Client.js:
Resolvido colocando a linha abaixo em Client.js:
Does this resolve the 2.3X incompatibility definitively?
Solved by putting the line below in Client.js:
C:\Users\Administrator\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107 await page.deleteCookie({name:'wa_build',domain:'.web.whatsapp.com',path:'/'}); ^
TypeError: Cannot read properties of null (reading 'deleteCookie') at Client.initialize (C:\Users\Administrator\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v21.7.1
Resolvido colocando a linha abaixo em Client.js:
Isso resolve a incompatibilidade 2.3X definitivamente?
It works for me
Resolvido colocando a linha abaixo em Client.js:
C:\Usuários\Administrador\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107 await page.deleteCookie({nome:'wa_build',domínio:'.web.whatsapp.com',caminho :'/'}); ^
TypeError: Não é possível ler propriedades de null (lendo 'deleteCookie') em Client.initialize (C:\Users\Administrator\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107:24) no processo. processTicksAndRejections (nó: interno/processo/task_queues:95:5)
Node.js v21.7.1
It looks to me like your page object is null, check if your puppeteer browser is opening the page.
Resolvido colocando a linha abaixo em Client.js:
C:\Usuários\Administrador\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107 await page.deleteCookie({nome:'wa_build',domínio:'.web.whatsapp.com',caminho :'/'}); ^ TypeError: Não é possível ler propriedades de null (lendo 'deleteCookie') em Client.initialize (C:\Users\Administrator\Desktop\V35\node_modules\whatsapp-web.js\src\Client.js:107:24) no processo. processTicksAndRejections (nó: interno/processo/task_queues:95:5) Node.js v21.7.1
It looks to me like your page object is null, check if your puppeteer browser is opening the page.
its not opening because of that error
Solved by putting the line below in Client.js:
thanks, this one works perfectly on my side
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', }
I used this solution. It worked fine for some time, then it blocked my number stating that the number violated the commerce policy of WhatsApp
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?
await page.deleteCookie({name:'wa_build',domain:'.web.whatsapp.com',path:'/'});
Solved by putting the line below in Client.js:
Funcionou para mim.
Solved by putting the line below in Client.js:
It's working so far
It works well for me, it doesn't give me an error, but it doesn't save the session, it always generates the QR
Solved by putting the line below in Client.js:
thanks, this one works perfectly on my side
although it works for me, but keep in mind, I got warning message from whatsapp that my account is suspicious and will be inactive soon
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)
Same problem, any solution please?
/home/deploy/api-whatsapp/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')
Hello, someone was able to find a solution to the problem, I tried with the answer of the partner, although the error no longer jumps, but I ask me to rescan the qr code.
Same problem, any solution please?
/home/deploy/api-whatsapp/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')
try this:
async persist(indexHtml) {
// extract version from index (e.g. manifest-2.2206.9.json -> 2.2206.9)
let version;
if (indexHtml.match(/manifest-([\d\\.]+)\.json/) === null) {
return null;
} else {
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);
}
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
Where do I put it and in which file
On Thu, 28 Mar 2024, 5:48 pm Cristian Camilo Jimenez Riveros, < @.***> wrote:
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
— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/2789#issuecomment-2025542854, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZBSXR5AZA56MAYZD4DAIX3Y2Q3UTAVCNFSM6AAAAABDZFKY3KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRVGU2DEOBVGQ . You are receiving this because you commented.Message ID: @.***>
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
sure, but I already scanned the qr before, I don't want to rescan it every time I have to send messages, before this error, the session was saved and worked every time I ran the method.
The session is saved, you do not have to scan it just 1 time.
The code goes in the app.js is how it is. saves and reads the saved session.
The session is saved, you do not have to scan it just 1 time.
The code goes in the app.js is how it is. saves and reads the saved session.
the session is saved at the first scan, but if I stop the application, it asks to scan the qr again.
I solved it with the code I provided, I saw that the problem was in how I called the saved session.
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.
A sessão é salva, você não precisa digitalizá-la apenas uma vez. O código vai no app.js é assim. salva e lê a sessão salva.
a sessão é salva na primeira varredura, mas se eu parar o aplicativo, ele pede para escanear o qr novamente.
Check if you are using LocalAuth like below:
const client = new Client({ authStrategy: new LocalAuth(), puppeteer: { // executablePath: "C:Program FilesGoogleChromeApplicationchrome.exe", // headless: true, args: ["--no-sandbox"], }, webVersionCache: { type: "remote", remotePath: "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html", }, });
it still does not work, I have multiple sessions saved, from several phones, in only some I have the problem that the index error pops up. I tried your own solutions and it doesn't work, it keeps asking me to scan the qr when I already scanned it the previous time.
this is how I use it, every time I want to send messages, I send messages according to the phone id and based on that I look for the saved session in the root of the project.
const dataPath = path.resolve(__dirname, '../Sesiones');
const sessionState = ObtenerSesionWhatsapp(idTelefono);
if (!sessionState) {
return res.status(400)
.send('Disconect');
}
const whatsappClient = new Client({
authStrategy: new LocalAuth({
clientId: `cliente-${idTelefono}`,
dataPath: dataPath,
}),
puppeteer: { headless: true },
webVersionCache: {
type: 'remote',
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html'
}
});
I solve the problem "Cannot read properties of null (reading '1')" by manually adding webVersion value match the .wwebjs_cache html version to the client
I solve the problem "Cannot read properties of null (reading '1')" by manually adding webVersion value match the .wwebjs_cache html version to the client
if you have more than one active session, more than one html is created in the wwebjs_cache, how do you know which one corresponds to each one, or if you have more than one synchronized phone?
I solve the problem "Cannot read properties of null (reading '1')" by manually adding webVersion value match the .wwebjs_cache html version to the client
if you have more than one active session, more than one html is created in the wwebjs_cache, how do you know which one corresponds to each one, or if you have more than one synchronized phone?
I am sorry, in my case just have one session active for now. I tried to place two version of html 2.2411.2 and latest 2.2412.50 and both can be used.
it still does not work, I have multiple sessions saved, from several phones, in only some I have the problem that the index error pops up. I tried your own solutions and it doesn't work, it keeps asking me to scan the qr when I already scanned it the previous time.
this is how I use it, every time I want to send messages, I send messages according to the phone id and based on that I look for the saved session in the root of the project.
const dataPath = path.resolve(__dirname, '../Sesiones');
const sessionState = ObtenerSesionWhatsapp(idTelefono); if (!sessionState) { return res.status(400) .send('Disconect'); } const whatsappClient = new Client({ authStrategy: new LocalAuth({ clientId: `cliente-${idTelefono}`, dataPath: dataPath, }), puppeteer: { headless: true }, webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2407.1.html' } });
I had tried to use webVersionCache with external link like you with partial success. Removing it (webVersionCache) and editing Client.js to remove the cookie wa_build has being more effective
Solved by putting the line below in Client.js:
thanks,, work for me.
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
where d i paste this code ??
some definitive solution?
I have two servers, one running Windows and the other running Ubuntu Server. I'm experiencing issues on Ubuntu, but not on Windows. I think that might be where the problem lies.
This worked for me by modifying the Client.js file
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.
can someone connect via team viewer and help me solve the issue of session not being able to be picked when i rerun the code... im prepared to pay you if u solve my whatsapp +263785866344
can someone connect via team viewer and help me solve the issue of session not being able to be picked when i rerun the code... im prepared to pay you if u solve my whatsapp +263785866344
Read more here :
hello i opened this : https://github.com/pedroslopez/whatsapp-web.js/issues/2856 and wrapped up everything related to the current discussed issue, from causes to technical details to workarounds in one place, please keep it open
https://github.com/pedroslopez/whatsapp-web.js/issues/1795#issuecomment-1312574765 removing the session worked for me, according to the comment above
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.
@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.
@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
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.
not work now
apparently WhatsApp has finally switched to Comet. Deleting cookies doesn't help, all accounts have this error
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
Is there an existing issue for this?
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
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
moduleraid
library (Related issue - https://github.com/pedroslopez/moduleRaid/issues/5)