Skip to content

Help Needed: Puppeteer Protocol Error - "Promise was collected" #249

Open
@maxyuri99

Description

Hello everyone,

I'm encountering a recurring issue while using Puppeteer in conjunction with whatsapp-web.js. My server is returning the following error:

ProtocolError: Protocol error (Runtime.callFunctionOn): Promise was collected
at /usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:329:24
at new Promise ()
at CDPSessionImpl.send (/usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:325:16)
at ExecutionContext._ExecutionContext_evaluate (/usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:211:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (/usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:107:16)
at async Client.getChatById (/usr/src/app/node_modules/whatsapp-web.js/src/Client.js:990:20)
at async Client. (/usr/src/app/src/sessions.js:252:24)
{
originalMessage: 'Promise was collected'
}

It seems that the error occurs when trying to execute a function in the page context, but the associated Promise has been collected by the Garbage Collector before it could be resolved.

I've ensured that I'm correctly using await for all asynchronous calls, but the issue persists. The error typically occurs during the getChatById method call. Here’s a brief overview of what I’m doing:

I’m retrieving a chat by ID using client.getChatById(chatId).
This operation sometimes leads to the mentioned ProtocolError.
Steps I've taken:

Verified that all Promises are awaited.
Checked for potential issues in code flow that might lead to premature Promise collection.
Updated to the latest versions of puppeteer-core and whatsapp-web.js.
Has anyone else encountered this issue? Any insights or suggestions on how to resolve or further debug this problem would be greatly appreciated.

Thank you!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions