Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxyuri99 opened this issue Aug 11, 2024 · 0 comments
Open

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

maxyuri99 opened this issue Aug 11, 2024 · 0 comments

Comments

@maxyuri99
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant