Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

[BUG] Messages that fail to send due to timeout don't throw an error.

Open angel-rs opened this issue 1 year ago • 11 comments

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 Screen Shot 2022-08-14 at 5 06 40 PM

To Reproduce Steps to reproduce the behavior:

  1. Have a production deployment of a whatsapp bot
  2. 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 to makeWASocket
 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.

angel-rs avatar Aug 14 '22 21:08 angel-rs

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...

undefined-60 avatar Aug 16 '22 11:08 undefined-60

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.

victorkelvin avatar Aug 16 '22 17:08 victorkelvin

+1

ajeelias avatar Aug 19 '22 21:08 ajeelias

+1 Waiting for this message issue

adarsh-chakraborty avatar Aug 22 '22 18:08 adarsh-chakraborty

+1

cassiano-guardianserver avatar Aug 26 '22 14:08 cassiano-guardianserver

+1

bagusrasuli avatar Aug 30 '22 01:08 bagusrasuli

I'm also having this problem. All the messages are not sent.

I'm using version 4.4.0

yonatann avatar Sep 01 '22 19:09 yonatann

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.

HoshenKadosh avatar Sep 04 '22 15:09 HoshenKadosh

+1

cassiano-guardianserver avatar Sep 08 '22 21:09 cassiano-guardianserver

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

github-actions[bot] avatar Sep 15 '22 04:09 github-actions[bot]

unstale

HoshenKadosh avatar Sep 16 '22 16:09 HoshenKadosh

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

github-actions[bot] avatar Sep 23 '22 04:09 github-actions[bot]

any fix?

cassiano-guardianserver avatar Sep 23 '22 12:09 cassiano-guardianserver

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

github-actions[bot] avatar Sep 30 '22 04:09 github-actions[bot]

unstale

HoshenKadosh avatar Oct 01 '22 19:10 HoshenKadosh

Guys, any fix?

guilhermeromer avatar Oct 07 '22 00:10 guilhermeromer

I am also facing a similar challenge here

aurthurm avatar Oct 12 '22 06:10 aurthurm

+1

gadhiamitul41 avatar Oct 13 '22 10:10 gadhiamitul41

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)

bagusrasuli avatar Oct 13 '22 17:10 bagusrasuli

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

github-actions[bot] avatar Oct 20 '22 03:10 github-actions[bot]

unstale

gadhiamitul41 avatar Oct 20 '22 05:10 gadhiamitul41

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

github-actions[bot] avatar Oct 27 '22 03:10 github-actions[bot]