Open
Description
Is there an existing issue for this?
- I have searched the existing issues.
Is this a problem caused by your code, or is it specifically because of the library?
- I have double-checked my code carefully.
Describe the bug.
The bot based on whatsapp-web.js with RemoteAuth and MongoDB storage is experiencing an issue where it authenticates twice in the same session, causing inconsistencies in its operation.
Additionally, although the bot logs that the client is ready to receive messages, it does not receive the message event, preventing it from responding to incoming messages.
Expected Behavior
Get ready and then start receaving messages

Steps to Reproduce the Bug or Issue
npm i
const { Client, RemoteAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");
const { MongoStore } = require("wwebjs-mongo");
const mongoose = require("mongoose");
const startBot = async () => {
await mongoose.connect(uri);
console.log("Conectado a MongoDB");
const store = new MongoStore({ mongoose: mongoose });
const client = new Client({
authStrategy: new RemoteAuth({
store: store,
backupSyncIntervalMs: 300000,
}),
});
client.once("ready", () => {
console.log("✅ Cliente listo!");
});
client.on("qr", (qr) => {
console.log("⚡ Escanea este código QR:");
qrcode.generate(qr, { small: true });
});
client.on("message_create", (message) => {
if (message.body === "!ping") {
client.sendMessage(message.from, "pong");
}
});
client.on("authenticated", () => {
console.log("🔑 Cliente autenticado");
});
client.on("remote_session_saved", () => {
console.log("💾 Sesión remota guardada");
});
client.initialize();
};
// Llamar a la función para evitar múltiples inicializaciones
startBot().catch((err) => console.error("Error al iniciar el bot:", err));
{
"name": "wp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"mongoose": "^8.10.1",
"qrcode-terminal": "^0.12.0",
"whatsapp-web.js": "^1.26.0",
"wwebjs-mongo": "^1.1.0"
}
}
WhatsApp Account Type
Standard
Browser Type
Chromium
Operation System Type
MAC
Phone OS Type
IOS
WhatsApp-Web.js Version
1.26.0
WhatsApp Web Version
na
Node.js Version
18.18.0
Authentication Strategy
LocalAuth
Additional Context
output:
Conectado a MongoDB
🔑 Cliente autenticado
✅ Cliente listo!
🔑 Cliente autenticado