[BUG][WEBJS] - TargetCloseError: Unexpected Closure of Puppeteer Browser Session During Contact Check
Describe the Bug
When attempting to check the existence of a contact using the /api/contacts/check-exists endpoint, an error occurs because the browser session unexpectedly closes. The Puppeteer library throws a "Protocol error (Runtime.callFunctionOn): Target closed" exception, which interrupts the WebJS session.
Title
"TargetCloseError: Puppeteer Browser Session Closed Unexpectedly During Contact Check"
Version
{
"version": "2024.12.1",
"engine": "WEBJS",
"tier": "PLUS",
"browser": "/usr/bin/chromium"
}
Docker logs
TargetCloseError: Protocol error (Runtime.callFunctionOn): Target closed at CallbackRegistry.clear (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:73:36) at CdpCDPSession._onClosed (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:101:25) at #onClose (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:167:21) at Connection.dispose (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:173:22) at CdpBrowser.disconnect (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Browser.js:230:26) at CdpBrowser.close (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Browser.js:226:20) at async WebjsClient.destroy (/app/node_modules/whatsapp-web.js/src/Client.js:787:9)
Hi! Could you try to switch to chrome based image? https://waha.devlike.pro/docs/how-to/engines/#docker-images
devlikeapro/waha-plus:chrome
Is there any error before that in docker logs, could you check?
docker compose logs
I won't be able to view the logs anymore. I've limited the logs by time, and they are being erased.
Hi! Could you try to switch to chrome based image? https://waha.devlike.pro/docs/how-to/engines/#docker-images
devlikeapro/waha-plus:chrome
Hi Will anything happen to my current sessions? I already have active working sessions at the moment
I've limited the logs by time, and they are being erased.
Do you mean you got the error only once or time to time, not always? In this case yeah, that's fine, just add a retry logic. It happens when browser got closed due to some internal issues, we restart it automatically, but it takes time (like a few seconds). Probably the request came into those seconds
I've limited the logs by time, and they are being erased.
Do you mean you got the error only once or time to time, not always? In this case yeah, that's fine, just add a retry logic. It happens when browser got closed due to some internal issues, we restart it automatically, but it takes time (like a few seconds). Probably the request came into those seconds
It's possible, but such behavior occurred specifically when checking the number for existence. That's why I decided to report it. Thank you for your response!
specifically when checking the number for existence
How often do you request it? It could be because of rate limits on the WA side :(
specifically when checking the number for existence
How often do you request it? It could be because of rate limits on the WA side :(
Before sending a message, I check if the number exists. How else can this be done? I need to be sure whether the message was successfully sent or not.
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)
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)
I'm currently using MongoDB to store sessions. If I update to 2025.1.4, will everything continue to work as before? I noticed that you've switched to PostgreSQL.
Is it possible to seamlessly change the engine, or will I need to reauthorize all sessions manually?
I noticed that you've switched to PostgreSQL.
Yes, we added PSQL support, not switched completely to it. It should work with no issue. We'll support MongoDB as long as possible (certainly the whole 2025)
Is it possible to seamlessly change the engine
Nope, as well as changing database type not possible :(