[BUG][WEBJS] - Duplicate Message Delivery Due to Promise was collected Error in whatsapp-web.js
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
}
}
@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.
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)
https://github.com/cyrus-and/chrome-remote-interface?tab=readme-ov-file#using-runtimeevaluate-with-awaitpromise-true-i-sometimes-obtain-error-promise-was-collected
Related #244
Will this issue be addressed in any way? Because it’s causing significant disruption. Or are there any alternative workarounds?
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)