waha icon indicating copy to clipboard operation
waha copied to clipboard

[BUG][WEBJS] - Duplicate Message Delivery Due to Promise was collected Error in whatsapp-web.js

Open Sabyrzhanuly opened this issue 1 year ago • 8 comments

When sending text through the whatsapp-web.js library, an error occurs: Protocol error (Runtime.callFunctionOn): Promise was collected. Despite the error, the message is successfully delivered. However, due to the error, the system treats the request as failed and re-sends the message, causing duplicate deliveries.

{
  "version": "2024.12.1",
  "engine": "WEBJS",
  "tier": "PLUS",
  "browser": "/usr/bin/chromium"
}

logs

      "request": {
        "body": {
          "text": "Test message",
          "chatId": "77771669474",
          "session": "4849012"
        },
        "path": "/api/sendText",
        "query": {
          
        },
        "method": "POST"
      },
      "version": {
        "tier": "PLUS",
        "engine": "WEBJS",
        "browser": "/usr/bin/chromium",
        "version": "2024.12.1"
      },
      "exception": {
        "name": "ProtocolError",
        "stack": "ProtocolError: Protocol error (Runtime.callFunctionOn): Promise was collected\n    at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:94:14)\n    at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:98:16)\n    at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:23:26)\n    at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:90:26)\n    at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:66:33)\n    at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:360:50)\n    at ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:275:36)\n    at IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:30)\n    at CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:341:43)\n    at CdpFrame.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:104:27)\n    at CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:807:43)\n    at WebjsClient.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:956:44)\n    at WhatsappSessionWebJSPlus.sendText (/app/dist/core/engines/webjs/session.webjs.core.js:289:30)\n    at ChattingController.sendText (/app/dist/api/chatting.controller.js:30:25)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)",
        "message": "Protocol error (Runtime.callFunctionOn): Promise was collected"
      },
      "timestamp": "2024-12-29T09:09:41.740Z",
      "statusCode": 500
    }
  }

patron:PLUS

Sabyrzhanuly avatar Dec 29 '24 09:12 Sabyrzhanuly

@devlikepro

Could you please take a look at this issue? The error leads to duplicate message deliveries, which impacts the messaging process reliability. Let me know if you need more details or logs to diagnose the problem.

patron:PLUS

Sabyrzhanuly avatar Dec 30 '24 06:12 Sabyrzhanuly

Hi! We'll double check that ASAP!

patron:PRO

devlikepro avatar Dec 30 '24 07:12 devlikepro

Related https://github.com/devlikeapro/waha/issues/244

patron:PRO

devlikepro avatar Dec 30 '24 08:12 devlikepro

ProtocolError: Protocol error (Runtime.callFunctionOn): Promise was collected
    at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:94:14)
    at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:98:16)
    at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:23:26)
    at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:90:26)
    at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:66:33)
    at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:360:50)
    at ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:275:36)
    at IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:30)
    at CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:341:43)
    at CdpFrame.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:104:27)
    at CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:807:43)
    at WebjsClient.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:956:44)
    at WhatsappSessionWebJSPlus.sendText (/app/dist/core/engines/webjs/session.webjs.core.js:289:30)
    at ChattingController.sendText (/app/dist/api/chatting.controller.js:30:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

patron:PRO

devlikepro avatar Dec 30 '24 08:12 devlikepro

https://github.com/cyrus-and/chrome-remote-interface?tab=readme-ov-file#using-runtimeevaluate-with-awaitpromise-true-i-sometimes-obtain-error-promise-was-collected

patron:PRO

devlikepro avatar Dec 30 '24 08:12 devlikepro

Related #244

patron:PRO

Will this issue be addressed in any way? Because it’s causing significant disruption. Or are there any alternative workarounds?

patron:PLUS

Sabyrzhanuly avatar Dec 30 '24 11:12 Sabyrzhanuly

Is there a solution? Could you please advise? @devlikepro

patron:PLUS

Sabyrzhanuly avatar Jan 03 '25 11:01 Sabyrzhanuly

Hi! Could you try to update to 2025.1.4 🙏 We've removed few dubious flags when starting chrome/chromium process, it should give a bit more stabilitiy (but may consume a bit more resources)

patron:PRO

devlikepro avatar Jan 19 '25 09:01 devlikepro

Hi! We've updated chrome and puppeter in 2025.4.2 and added a global error handler for some common issues (it'll restart browser if it get any errors like ProtocolError)

It won't fix all such errors, but should reduce the amount a lot.

patron:PRO

devlikepro avatar May 05 '25 06:05 devlikepro