Baileys
Baileys copied to clipboard
[BUG] Messages that fail to send due to timeout don't throw an error.
Describe the bug
Some messages fail to send due to timeout.await sock.sendMessage(waId, params)
does NOT throw. So cannot handle these cases (e.g: retry on a background job to guarantee that the message is sent.
Here's the error from Sentry:
![Screen Shot 2022-08-14 at 5 07 01 PM](https://user-images.githubusercontent.com/20560880/184554904-d06f7a09-24ca-4305-860a-84513b8c27b4.png)
![Screen Shot 2022-08-14 at 5 06 40 PM](https://user-images.githubusercontent.com/20560880/184554895-5eff50f7-07bf-43b8-b742-12355e99388f.png)
To Reproduce Steps to reproduce the behavior:
- Have a production deployment of a whatsapp bot
- Send a bunch of messages
Expected behavior
- the function call to send message should throw with the timeout error, so it can be handled properly. e.g: retry.
- In the last 30d it has happened 10 times.
- Don't have stats on how many messages the bot sends. But must be on the thousands.
Environment (please complete the following information):
- Is this on a server? Yes
- What do your
connectOptions
look like? I assume this refers tomakeWASocket
wa.state = await getSession();
wa.sock = makeWASocket({
auth: wa.state,
printQRInTerminal: true,
browser: ["Ibis", "Chrome", "1.0"],
version,
});
- Do you have multiple clients on the same IP? No. 1 Server 1 WA Number
- Are you using a proxy? No
Additional context
- Using
bed9e38
commit sha. w/ patch to make template buttons work on android. - Been running this same config for 9months. This error started surfacing 3months ago.
- Whatsapp messages are sent on a background job.
- I even added logs to see what happens, my current
sendMessage
implementation looks like this:
try {
await wa.sock.sendMessage(to, params);
consola.log("[WHATSAPP_DEBUG] - Successfully sent message");
} catch (e) {
consola.log("[WHATSAPP_DEBUG] - error");
consola.log(e);
throw e;
}
-
sendMessage
never prints the "error" log. i.e: never throws - I'm on discord. Both WA-Multi-Device & WaWebSockets.
- Also posted this error on Discord.
As vezes sinto que ocorre este erro aqui, executo um comando para enviar tal mensagem mais algumas vezes, raras, as mensagens não são enviadas, algumas...
I'm facing a similar problem that the message isn't delivered to the receipers. The message keeps with that "waiting for message" notification. And no error is thrown by the socket.
+1
+1 Waiting for this message issue
+1
+1
I'm also having this problem. All the messages are not sent.
I'm using version 4.4.0
Same issue. Seems like this happens mostly when WA closes the connection while sending, I have my retry outside the socket scope so if it fails I can retry on the new socket, but I can't know it failed because it doesn't throw.
(node:6924) UnhandledPromiseRejectionWarning: Error: Timed Out at C:\snapshot\wa-broadcaster\node_modules\@adiwajshing\baileys\lib\Utils\generics.js:157:32
@adiwajshing can you please have a look at this? this seems like a quite popular edge case for people who send many messages.
+1
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
unstale
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
any fix?
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
unstale
Guys, any fix?
I am also facing a similar challenge here
+1
I have similar issue, it seems when I try to send message to contact that I had already sent before, it often not delivered, even though I get the success response and key_id from Whatsapp. (I send hundreds message everyday)
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
unstale
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days