Closed Biel-007 closed 5 months ago
I have a similar problem, when i scannig the QR code.
Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
at puppeteer_evaluation_script:5:95
at ExecutionContext._evaluateInternal (node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at runMicrotasks (
I have a similar problem, which occurred a few years ago and is occurring now and without any solution. I ask that the moderator does not close the ticket, as there are no resolutions for this issue in the latest version v1.23.1-alpha.5.
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 (/opt/1003/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 (/opt/1003/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async Client.initialize (/opt/1003/node_modules/whatsapp-web.js/src/Client.js:323:9)
Evaluation failed: TypeError: Cannot read properties of undefined (reading 'WidFactory') at _puppeteer_evaluation_script_:2:42
My code was working perfectly for many months, about 4 days ago the service stopped working, and after redoing it from scratch, the client can read the qrcode normally, the service starts working again and after a few hours it stops again, generating the error above.
My code:
const { Client, LocalAuth } = require('whatsapp-web.js');
const express = require('express');
const { body, query, validationResult } = require('express-validator');
const socketIO = require('socket.io');
const qrcode = require('qrcode');
const http = require('http');
const axios = require('axios');
const mime = require('mime-types');
const port = process.env.PORT || 1003;
const app = express();
const server = http.createServer(app);
const io = socketIO(server);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/", express.static(__dirname + "/"))
app.get('/', (req, res) => {
res.sendFile('index.html', { root: __dirname });
});
const client = new Client({
authStrategy: new LocalAuth({ clientId: 'DacTracker' }),
puppeteer: {
// executablePath: '/opt/google/chrome/google-chrome',
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--single-process',
'--disable-gpu',
'--disable-extensions'
]
}
});
client.initialize();
let isConnected = false;
let isReady = false;
let isAuthenticated = false;
// Aumentar o limite de ouvintes para o objeto client
client.setMaxListeners(15);
io.on('connection', function(socket) {
socket.emit('message', 'Sessão iniciada, gerando QrCode...');
socket.emit('qr', './assets/whatsapp.svg');
if (isAuthenticated) {
socket.emit('authenticated', 'Dispositivo Autenticado');
socket.emit('message', 'Dispositivo Autenticado');
if (isConnected) {
socket.emit('qr', './assets/check.svg');
}
}
if (isConnected) {
socket.emit('ready', 'Dispositivo Conectado');
socket.emit('message', 'Dispositivo Conectado');
if (isAuthenticated) {
socket.emit('qr', './assets/check.svg');
}
}
socket.on('message', function(msg) {
var logElement = $('<div>').addClass('alert alert-success').text(msg);
$('.logs').empty().append(logElement); // Substitui o conteúdo da div
});
});
client.on('qr', (qr) => {
console.log('QR RECEIVED', qr);
qrcode.toDataURL(qr, (err, url) => {
io.emit('qr', url);
io.emit('message', 'QrCode gerado, acesse seu whatsapp para scanear.');
});
});
client.on('authenticated', () => {
isAuthenticated = true;
io.emit('authenticated', 'Dispositivo Autenticado');
io.emit('message', 'Dispositivo Autenticado');
if (isConnected) {
io.emit('qr', './assets/check.svg');
}
console.log('Dispositivo Autenticado');
});
client.on('ready', () => {
isConnected = true;
isReady = true;
io.emit('ready', 'Dispositivo Conectado');
io.emit('message', 'Dispositivo Conectado');
if (isAuthenticated) {
io.emit('qr', './assets/check.svg');
}
console.log('Dispositivo Conectado');
});
client.on('auth_failure', function() {
io.emit('message', 'Falha na autenticação, reiniciando...');
console.error('Falha na autenticação, reiniciando...');
});
client.on('disconnected', (reason) => {
isConnected = false;
isReady = false;
isAuthenticated = false;
io.emit('message', 'Dispositivo Desconectado');
console.log('Dispositivo Desconectado', reason);
client.destroy();
client.initialize();
});
// Send message Post
app.post('/send-message', [
body('number').notEmpty(),
body('message').notEmpty(),
], async (req, res) => {
const errors = validationResult(req).formatWith(({ msg }) => {
return msg;
});
if (!errors.isEmpty()) {
return res.status(422).json({
status: false,
message: errors.mapped()
});
}
const number = req.body.number;
const numberDDI = number.substr(0, 2);
const numberDDD = number.substr(2, 2);
const numberUser = number.substr(-8, 8);
const message = req.body.message;
if (numberDDI !== "55") {
const numberZDG = number + "@c.us";
client.sendMessage(numberZDG, message).then(response => {
res.status(200).send('Mensagem enviada com sucesso!');
}).catch((err) => {
res.status(500).send('Erro ao enviar a mensagem: ' + err.message);
});
} else if (numberDDI === "55" && parseInt(numberDDD) <= 30) {
const numberZDG = "55" + numberDDD + "9" + numberUser + "@c.us";
client.sendMessage(numberZDG, message).then(response => {
res.status(200).send('Mensagem enviada com sucesso!');
}).catch((err) => {
res.status(500).send('Erro ao enviar a mensagem: ' + err.message);
});
} else if (numberDDI === "55" && parseInt(numberDDD) > 30) {
const numberZDG = "55" + numberDDD + numberUser + "@c.us";
client.sendMessage(numberZDG, message).then(response => {
res.status(200).send('Mensagem enviada com sucesso!');
}).catch((err) => {
res.status(500).send('Erro ao enviar a mensagem: ' + err.message);
});
}
});
server.listen(port, function() {
console.log('SERVIDOR INICIADO NA PORTA: *:' + port);
});
Node: 18.19.0 Ubuntu 22
possible solution, it worked for me
1 - Go to "whatsapp-web.js/util/Constants.js"
2 - where is
webVersionCache: {
type: 'local',
},
Switch to
webVersionCache: {
type: 'remote',
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html',
},
this should work
try it and tell me if works
possible solution, it worked for me
1 - Go to "whatsapp-web.js/util/Constants.js"
2 - where is
webVersionCache: { type: 'local', },
Switch to
webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html', },
this should work
I had the same error here and it worked for me
possible solution, it worked for me 1 - Go to "whatsapp-web.js/util/Constants.js" 2 - where is
webVersionCache: { type: 'local', },
Switch to
webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html', },
this should work
I had the same error here and it worked for me
os BRs se entendem kkk
Vou experimentar, provavelmente só tenha uma resposta amanhã, visto que o serviço fica em funcionamento por várias horas e depois para gerando o erro.
Vou experimentar, provavelmente só tenha uma resposta amanhã, visto que o serviço fica em funcionamento por várias horas e depois para gerando o erro.
acho que o erro é devido a alguma atualização do whatsapp web
Você experimentará, provavelmente só tenha uma resposta amanhã, visto que o serviço fica em funcionamento por várias horas e depois para gerar o erro.
Acho que o erro é devido a alguma atualização do WhatsApp Web
Sim, foi isso mesmo. O cliente relatou essa atualização no dia seguinte quando parou o serviço. Mas até então não há nenhuma forma oficial de resolver certo? Tentei mandar um ticket mas o moderador fechou! Esse problema ocorreu em 2020 e houve soluções parciais para resolver, isso naquele ano, a mesma solução pra agora não funciona. Vou torcer para que essa que você me passou funcione. Desde já obrigado
possible solution, it worked for me
1 - Go to "whatsapp-web.js/util/Constants.js"
2 - where is
webVersionCache: { type: 'local', },
Switch to
webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html', },
this should work
Work for me
But what is this url about, will we all be sharing the same cache? I'm worried that we all use the same url, without knowing what it is about.
possible solution, it worked for me 1 - Go to "whatsapp-web.js/util/Constants.js" 2 - where is
webVersionCache: { type: 'local', },
Switch to
webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html', },
this should work
Work for me
But what is this url about, will we all be sharing the same cache? I'm worried that we all use the same url, without knowing what it is about.
this link is just a template, wweb will create the cache using this template on your own computer theoretically that would be
Você experimentará, provavelmente só tenha uma resposta amanhã, visto que o serviço fica em funcionamento por várias horas e depois para gerar o erro.
Acho que o erro é devido a alguma atualização do WhatsApp Web
Sim, foi isso mesmo. O cliente relatou essa atualização no dia seguinte quando parou o serviço. Mas até então não há nenhuma forma oficial de resolver certo? Tentei mandar um ticket mas o moderador fechou! Esse problema ocorreu em 2020 e houve soluções parciais para resolver, isso naquele ano, a mesma solução pra agora não funciona. Vou torcer para que essa que você me passou funcione. Desde já obrigado
acho que estão resolvendo, até porque como essa API não é oficial, não temos muito o que fazer kkk mas fico feliz em ajudar 😄
Após iniciar o serviço a pasta .wwebjs_cache não foi mais criada, somente a .wwebjs_auth. É normal? devido a alteração que fizemos?
possible solution, it worked for me 1 - Go to "whatsapp-web.js/util/Constants.js" 2 - where is
webVersionCache: { type: 'local', },
Switch to
webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html', },
this should work
Work for me But what is this url about, will we all be sharing the same cache? I'm worried that we all use the same url, without knowing what it is about.
this link is just a template, wweb will create the cache using this template on your own computer theoretically that would be
Oh very good. This solution works for me. thank you
Is there an existing issue for this?
Describe the bug
D:\Projetos\sizezap srv\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 (D:\Projetos\sizezap srv\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69) at D:\Projetos\sizezap srv\node_modules\whatsapp-web.js\src\Client.js:757:36 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Expected behavior
he expected would be to start the client normally
Steps to Reproduce the Bug or Issue
just start the client
Relevant Code
const client = new Client({ authStrategy: new LocalAuth({ dataPath:
sessoes\\${chave}_${id}
})
});
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Windows Phone OS: Android whatsapp-web.js version: 1.23.0 WhatsApp Web version: the most recent Node.js Version : 20.11.1
Additional context