[Bug]: Retrieving the contact list is not working at all. 500 - Internal server error
Pre-flight
- [x] I searched existing issues and this isn't a duplicate
- [x] I'm on the latest released version (or noted my version below)
OpenWA version
0.23.3
Deployment
Docker Compose
Database
SQLite (default)
WhatsApp engine
whatsapp-web.js
What happened?
Hello,
I have noticed that in recent versions, from 10 onwards up to the current release, we can no longer fetch contact lists via the endpoint:
/api/sessions/{sessionId}/contacts
When fetching the contact list, it returns a 500 - Internal server error.
Any Help ,
Steps to reproduce
returns a 500 - Internal server error
Expected behavior
No response
Relevant logs
Environment / additional context
No response
Thanks for the report. I need two things to place this, because a 500 from that route can come from several different causes and the HTTP body will not distinguish them.
1. The container log around the failure. The response body carries nothing useful, but the gateway logs the underlying error. Please run the request and then:
docker compose logs --tail=200 <service-name>
and paste the lines around the 500. The first line of the stack is what separates the possibilities.
2. Roughly how many contacts are on that account, and whether GET /api/sessions/{sessionId}/chats works on the same session.
The most likely cause, and something to try now
GET /contacts reads the entire contact store in a single browser command; the limit/offset parameters trim the response afterwards, in the gateway, not in the browser. Puppeteer gives every browser command a fixed budget, 180 000 ms by default, and on a large account that read can run past it. The command is dropped while the renderer is still working, which is why the session stays ready and everything else keeps working, and why it reproduces every single time on the affected account while smaller accounts on the same deployment are fine. That matches "not working at all" for this one endpoint.
If that is what is happening, the log line will name a CDP method and the setting, something like:
Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect
calls for a higher timeout if needed.
The budget is now configurable:
PUPPETEER_PROTOCOL_TIMEOUT_MS=300000
One caveat on availability: this landed on main and is not in 0.23.3, so it will reach you in the next release. If you are able to run from main before then, setting it is the fastest way to confirm or rule out this theory.
If the log shows something else, paste it and I will take it from there. Please keep this open either way, since the diagnosis is not settled yet.
Hi @rmyndharis thank u for response this log :
openwa-api | [Nest] 7 - 08/30/2026, 7:20:14 PM LOG [EventsGateway] Client disconnected: GGiJXRJTh87TNfHOAAYT
openwa-api | [Nest] 7 - 08/30/2026, 7:20:14 PM LOG [EventsGateway] Client disconnected: yaQt6xoFGwSCs9ObAAYS
openwa-api | [Nest] 7 - 08/30/2026, 7:20:15 PM LOG [EventsGateway] Client connected: wNwYxxsyum2peD_0AAYW (key: Default Admin Key)
openwa-api | [Nest] 7 - 08/30/2026, 7:20:15 PM LOG [EventsGateway] Client connected: diOytdQJMTL4VI6-AAYX (key: Default Admin Key)
openwa-api | [Nest] 7 - 08/30/2026, 7:20:15 PM DEBUG [EventsGateway] Client wNwYxxsyum2peD_0AAYW subscribed to: session:ca90bdce-577b-4597-8cac-9591d3b78b7d:*
openwa-api | [Nest] 7 - 08/30/2026, 7:20:15 PM DEBUG [EventsGateway] Client diOytdQJMTL4VI6-AAYX subscribed to: session:ca90bdce-577b-4597-8cac-9591d3b78b7d:*
openwa-api | {"timestamp":"2026-08-30T19:20:39.539Z","level":"warn","context":"SessionLivenessWatchdog","message":"Liveness probe failed; will treat the session as dead after repeated failures","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","failures":1,"action":"watchdog_probe_failed"}
openwa-api | [Nest] 7 - 08/30/2026, 7:21:15 PM LOG [EventsGateway] Client disconnected: wNwYxxsyum2peD_0AAYW
openwa-api | [Nest] 7 - 08/30/2026, 7:21:15 PM LOG [EventsGateway] Client disconnected: diOytdQJMTL4VI6-AAYX
openwa-api | [Nest] 7 - 08/30/2026, 7:21:15 PM LOG [EventsGateway] Client connected: fP48owTD0qwzSS8VAAYa (key: Default Admin Key)
openwa-api | [Nest] 7 - 08/30/2026, 7:21:16 PM LOG [EventsGateway] Client connected: u7EpOqQj5kT9WkSNAAYb (key: Default Admin Key)
openwa-api | [Nest] 7 - 08/30/2026, 7:21:16 PM DEBUG [EventsGateway] Client fP48owTD0qwzSS8VAAYa subscribed to: session:ca90bdce-577b-4597-8cac-9591d3b78b7d:*
openwa-api | [Nest] 7 - 08/30/2026, 7:21:16 PM DEBUG [EventsGateway] Client u7EpOqQj5kT9WkSNAAYb subscribed to: session:ca90bdce-577b-4597-8cac-9591d3b78b7d:*
openwa-api | {"timestamp":"2026-08-30T19:21:30.593Z","level":"warn","context":"SessionLivenessWatchdog","message":"Liveness probe failed; will treat the session as dead after repeated failures","sessionId":"4905ee2b-8f5b-416c-8d7e-3fd93e3636bb","failures":1,"action":"watchdog_probe_failed"}
openwa-api | {"timestamp":"2026-08-30T19:21:39.551Z","level":"warn","context":"SessionLivenessWatchdog","message":"Liveness probe failed repeatedly; handling the session as disconnected","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","failures":2,"action":"watchdog_disconnect"}
openwa-api | {"timestamp":"2026-08-30T19:21:39.744Z","level":"warn","context":"SessionEngineLifecycle","message":"Session disconnected: liveness probe failed (watchdog)","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","reason":"liveness probe failed (watchdog)","action":"disconnected"}
openwa-api | {"timestamp":"2026-08-30T19:21:39.748Z","level":"info","context":"SessionEngineLifecycle","message":"Scheduling reconnect attempt 1/∞ in 6s","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","attempt":1,"delayMs":5682.420929326494,"action":"reconnect_scheduled"}
openwa-api | {"timestamp":"2026-08-30T19:21:52.790Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Page transport error during getContacts — treating the session as dead","error":"Protocol error (Runtime.callFunctionOn): Target closed","requestId":"0432dc57-1414-4e4e-97fe-fb9018d722fe"}
openwa-api | [Nest] 7 - 08/30/2026, 7:21:52 PM ERROR [ExceptionsHandler] TargetCloseError: Protocol error (Runtime.callFunctionOn): Target closed
openwa-api | at CallbackRegistry.clear (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:82:36)
openwa-api | at CdpCDPSession.onClosed (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:115:25)
openwa-api | at Connection.onMessage (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:149:25)
openwa-api | at WebSocket.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:43:32)
openwa-api | at callListener (/app/node_modules/ws/lib/event-target.js:290:14)
openwa-api | at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:209:9)
openwa-api | at WebSocket.emit (node:events:519:28)
openwa-api | at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1239:20)
openwa-api | at Receiver.emit (node:events:519:28)
openwa-api | at Immediate.<anonymous> (/app/node_modules/ws/lib/receiver.js:655:16)
openwa-api | at process.processImmediate (node:internal/timers:484:21)
openwa-api | at process.callbackTrampoline (node:internal/async_hooks:130:17) {
openwa-api | cause: ProtocolError
openwa-api | at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:103:14)
openwa-api | at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:107:16)
openwa-api | at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:25:26)
openwa-api | at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:108:26)
openwa-api | at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:74:33)
openwa-api | at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:363:50)
openwa-api | at ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277:36)
openwa-api | at IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:30)
openwa-api | at CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:362:43)
openwa-api | at CdpFrame.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:109:27)
openwa-api | at CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:830:43)
openwa-api | at Client.getContacts (/app/node_modules/whatsapp-web.js/src/Client.js:1737:43)
openwa-api | at WwebjsContacts.getContacts (/app/dist/engine/adapters/wwebjs-contacts.js:18:50)
openwa-api | at WhatsAppWebJsAdapter.getContacts (/app/dist/engine/adapters/whatsapp-web-js.adapter.js:341:30)
openwa-api | at ContactService.getContacts (/app/dist/modules/contact/contact.service.js:31:14)
openwa-api | at ContactController.findAll (/app/dist/modules/contact/contact.controller.js:30:36)
openwa-api | }
openwa-api | {"timestamp":"2026-08-30T19:21:55.457Z","level":"error","context":"SessionEngineLifecycle","message":"Failed to destroy engine for session ca90bdce-577b-4597-8cac-9591d3b78b7d","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","action":"engine_destroy_failed","trace":"Error: engine.destroy() timed out"}
openwa-api | {"timestamp":"2026-08-30T19:21:55.463Z","level":"info","context":"SessionEngineLifecycle","message":"Initializing engine for session: essam-art","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","action":"engine_init","proxyEnabled":false}
openwa-api | {"timestamp":"2026-08-30T19:21:55.515Z","level":"info","context":"WhatsAppWebJsAdapter","message":"Pinning WhatsApp Web version 2.3000.1046291534-alpha"}
openwa-api | {"timestamp":"2026-08-30T19:21:55.519Z","level":"info","context":"WhatsAppWebJsAdapter","message":"Using auth timeout 120000ms"}
openwa-api | [Nest] 7 - 08/30/2026, 7:22:14 PM LOG [EventsGateway] Client disconnected: u7EpOqQj5kT9WkSNAAYb
openwa-api | [Nest] 7 - 08/30/2026, 7:22:14 PM LOG [EventsGateway] Client disconnected: fP48owTD0qwzSS8VAAYa
openwa-api | {"timestamp":"2026-08-30T19:22:19.542Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"\"Protocol error (Runtime.callFunctionOn): Execution context was destroyed.\" killed the first inject — a page navigation landed before whatsapp-web.js installed its re-inject handler. Retrying the launch once (#1081).","sessionId":"essam-art","action":"init_navigation_retry"}
openwa-api | {"timestamp":"2026-08-30T19:22:32.641Z","level":"info","context":"SessionEngineLifecycle","message":"QR code generated","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","action":"qr_generated"}
openwa-api | {"timestamp":"2026-08-30T19:22:32.642Z","level":"warn","context":"SessionEngineLifecycle","message":"Previously linked session is asking for a QR again: its stored credentials are missing or no longer accepted. Unless an earlier warning for this session (LOGOUT, auth_cleared) or a changed ENGINE_TYPE explains it, WhatsApp dropped the link while the engine was down (unlinked from the phone, expired while offline, or the engine's stored auth state was lost). Check Linked devices on the phone before re-pairing.","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","action":"relink_required"}
@rmyndharis : After the error appeared, I adjusted the value as you instructed:
PUPPETEER_PROTOCOL_TIMEOUT_MS=300000
, and everything is working correctly now.
Thank you very much.
@rmyndharis This error still appears even when I've configured the settings (PUPPETEER_PROTOCOL_TIMEOUT_MS=300000
) times — it works normally sometimes and other times it doesn't:
openwa-api | [Nest] 7 - 08/31/2026, 10:50:49 AM ERROR [ExceptionsHandler] TargetCloseError: Protocol error (Runtime.callFunctionOn): Target closed
Thank you for the log, and for coming back with the second report. Together they move the diagnosis away from where I first pointed you, so let me correct it.
There are two different failures here, and PUPPETEER_PROTOCOL_TIMEOUT_MS only addresses one of them. That is why raising it worked and then stopped working. The one you are hitting now is ours, and it is not really about contacts at all.
What your log shows
Reading the timestamps in order, for session ca90bdce:
19:20:39 watchdog_probe_failed failures: 1
19:21:39 watchdog_disconnect failures: 2 -> the gateway concludes the session is dead
19:21:39 Scheduling reconnect attempt 1
19:21:52 Page transport error during getContacts: Target closed
The contacts call fails after the gateway has already decided the session is dead, not before. That ordering is the important part. If the browser page had genuinely died on its own, your pending contacts request would have failed at that moment, a full minute earlier. Instead it stayed alive across both failed probes and only died when our own reconnect closed the browser underneath it.
So the session was not dead. It was busy, and what was keeping it busy was the contacts read itself.
The mechanism
The gateway checks every session is alive once a minute, and gives that check 10 seconds to answer. Both that check and the contacts read run inside the same browser page, so they take turns. Reading a large address book occupies that page in one uninterrupted stretch, and while it does, the health check cannot get a turn and times out. Two of those in a row, 60 seconds apart, and the gateway concludes the session is gone, reconnects, and closes the browser on top of the read that was still running.
I have reproduced the starving part against a real browser, and filed it as #1501 with the details. It affects any long read, not just contacts.
This also explains the sequence you saw: raising the protocol timeout fixed the case where the read exceeded Puppeteer's own budget, which is a genuinely different error. It has no effect on the health check, and by letting a slow read stay on the page for longer, it can make this second failure more likely rather than less.
Two things that would confirm it
- Roughly how many contacts are on that account, and roughly how many of them are WhatsApp Business accounts? The second number matters more than it sounds: business contacts make the read pause naturally, which lets the health check through. A mostly personal address book is the case that starves it.
- In the log for a fresh occurrence, does a
watchdog_probe_failedline withfailures: 1appear about 60 seconds before eachTarget closed? If it does, that is the same shape confirmed on your deployment rather than inferred from one capture.
Meanwhile
There is no configuration that fixes this today, and I would rather not suggest one that does not work. Calling the contacts endpoint while nothing else needs that session, and expecting one call to take as long as it takes, is the best that can be done until the fix lands. Please leave PUPPETEER_PROTOCOL_TIMEOUT_MS where you set it; it is still doing useful work on the other failure.
Keeping this open and tracking the fix in #1501.
Welcome @rmyndharis , thank you for your reply, and I appreciate the massive fixes you've made in the new updates.
Of course, regarding contacts, at any point we define them with limit and offset in order to reduce the load on the connection. This issue is currently not a major problem; it works excellently most of the time. Here is the latest log:
[Nest] 8 - 09/02/2026, 12:22:02 PM DEBUG [EventsGateway] Client Nq2hkOXHmgjRq4l4AAie subscribed to: session:4905ee2b-8f5b-416c-8d7e-3fd93e3636bb:*
{"timestamp":"2026-09-02T12:22:35.233Z","level":"warn","context":"SessionEngineLifecycle","message":"Session disconnected: Page crashed","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","reason":"Page crashed","action":"disconnected","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:22:35.238Z","level":"info","context":"SessionEngineLifecycle","message":"Scheduling reconnect attempt 1/∞ in 5s","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","attempt":1,"delayMs":5446.0026228643555,"action":"reconnect_scheduled","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:22:40.762Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Page transport error during getBlockedContacts — treating the session as dead","error":"Protocol error (Runtime.callFunctionOn): Target closed","requestId":"37ced2d0-50ea-4bb8-83d7-f81398fca93a"}
{"timestamp":"2026-09-02T12:22:40.763Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Page transport error during getContacts — treating the session as dead","error":"Protocol error (Runtime.callFunctionOn): Target closed","requestId":"15e6bd57-d393-496a-8d6c-1d0f1a323ad3"}
[Nest] 8 - 09/02/2026, 12:22:40 PM ERROR [ExceptionsHandler] TargetCloseError: Protocol error (Runtime.callFunctionOn): Target closed
at CallbackRegistry.clear (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:82:36)
at CdpCDPSession.onClosed (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:115:25)
at Connection.onMessage (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:149:25)
at WebSocket.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:43:32)
at callListener (/app/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:209:9)
at WebSocket.emit (node:events:519:28)
at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1239:20)
at Receiver.emit (node:events:519:28)
at Immediate.<anonymous> (/app/node_modules/ws/lib/receiver.js:655:16)
at process.processImmediate (node:internal/timers:484:21)
at process.callbackTrampoline (node:internal/async_hooks:130:17) {
cause: ProtocolError
at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:103:14)
at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:107:16)
at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:25:26)
at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:108:26)
at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:74:33)
at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:363:50)
at ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277: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:362:43)
at CdpFrame.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:109:27)
at CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:830:43)
at Client.getBlockedContacts (/app/node_modules/whatsapp-web.js/src/Client.js:2884:52)
at WwebjsContacts.getBlockedContacts (/app/dist/engine/adapters/wwebjs-contacts.js:94:50)
at WhatsAppWebJsAdapter.getBlockedContacts (/app/dist/engine/adapters/whatsapp-web-js.adapter.js:476:30)
at ContactService.getBlockedContacts (/app/dist/modules/contact/contact.service.js:42:42)
at ContactController.getBlockedContacts (/app/dist/modules/contact/contact.controller.js:44:36)
}
[Nest] 8 - 09/02/2026, 12:22:40 PM ERROR [ExceptionsHandler] TargetCloseError: Protocol error (Runtime.callFunctionOn): Target closed
at CallbackRegistry.clear (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:82:36)
at CdpCDPSession.onClosed (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:115:25)
at Connection.onMessage (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:149:25)
at WebSocket.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:43:32)
at callListener (/app/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:209:9)
at WebSocket.emit (node:events:519:28)
at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1239:20)
at Receiver.emit (node:events:519:28)
at Immediate.<anonymous> (/app/node_modules/ws/lib/receiver.js:655:16)
at process.processImmediate (node:internal/timers:484:21)
at process.callbackTrampoline (node:internal/async_hooks:130:17) {
cause: ProtocolError
at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:103:14)
at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:107:16)
at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:25:26)
at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:108:26)
at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:74:33)
at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:363:50)
at ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277: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:362:43)
at CdpFrame.<anonymous> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:109:27)
at CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:830:43)
at Client.getContacts (/app/node_modules/whatsapp-web.js/src/Client.js:1737:43)
at WwebjsContacts.getContacts (/app/dist/engine/adapters/wwebjs-contacts.js:18:50)
at WhatsAppWebJsAdapter.getContacts (/app/dist/engine/adapters/whatsapp-web-js.adapter.js:341:30)
at ContactService.getContacts (/app/dist/modules/contact/contact.service.js:31:14)
at ContactController.findAll (/app/dist/modules/contact/contact.controller.js:30:36)
}
{"timestamp":"2026-09-02T12:22:41.144Z","level":"info","context":"SessionEngineLifecycle","message":"Initializing engine for session: essam-art","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","action":"engine_init","proxyEnabled":false,"requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:22:41.166Z","level":"info","context":"WhatsAppWebJsAdapter","message":"Pinning WhatsApp Web version 2.3000.1046395181-alpha","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:22:41.167Z","level":"info","context":"WhatsAppWebJsAdapter","message":"Using auth timeout 120000ms","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
[Nest] 8 - 09/02/2026, 12:22:49 PM LOG [EventsGateway] Client disconnected: t_1q_A-jO31ShPZeAAic
[Nest] 8 - 09/02/2026, 12:23:01 PM LOG [EventsGateway] Client disconnected: Nq2hkOXHmgjRq4l4AAie
[Nest] 8 - 09/02/2026, 12:23:01 PM LOG [EventsGateway] Client connected: kAk124QnUzbwV-NWAAig (key: واتس)
[Nest] 8 - 09/02/2026, 12:23:02 PM DEBUG [EventsGateway] Client kAk124QnUzbwV-NWAAig subscribed to: session:4905ee2b-8f5b-416c-8d7e-3fd93e3636bb:*
{"timestamp":"2026-09-02T12:23:04.253Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Page navigated; whatsapp-web.js is re-injecting","sessionId":"essam-art","action":"page_navigation_reinject_window","graced":true,"requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:23:07.129Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Ignoring premature ready: the message event bridge is not attached yet","sessionId":"essam-art","action":"premature_ready_ignored","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
{"timestamp":"2026-09-02T12:23:08.328Z","level":"info","context":"SessionEngineLifecycle","message":"Session ready: 967770701021","sessionId":"ca90bdce-577b-4597-8cac-9591d3b78b7d","phone":"967770701021","pushName":"عصام لحلول تقنية المعلومات","action":"ready","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}
Thank you for the new log. It rules out the mechanism I described last time, so this is a correction rather than a confirmation.
The watchdog is not involved in this occurrence
There is no watchdog_probe_failed line anywhere in the capture, and the disconnect reason is a different one:
12:22:35.233 Session disconnected: Page crashed
A watchdog kill reads Session disconnected: liveness probe failed (watchdog) and is always preceded by a watchdog_probe_failed line about 60 seconds earlier. Neither is here. Page crashed comes from our listener on Chromium's page error event, which fires on exactly one condition: the renderer process died. The page was not starved out by a long read. It died, and then our reconnect ran.
What the timestamps actually say
12:22:35.233 renderer dies, session marked disconnected
12:22:35.238 reconnect scheduled, delayMs 5446
12:22:40.762 getBlockedContacts fails, Target closed
12:22:40.763 getContacts fails, Target closed
12:22:41.144 new engine initializing
12:23:08.328 session ready
The 5.5 second gap is not the two reads surviving the crash. When a renderer dies, the browser commands already in flight are not rejected; they stay parked on the connection until something closes it. What closed it was our own reconnect, and its 5446 ms delay is the first attempt of the backoff. Both requests were lost at 12:22:35 and only found out at 12:22:40.
This also explains why it is intermittent rather than constant, which matches what you are seeing. Only a request already in flight when the renderer dies can produce this 500. A request that arrives after it gets a 409 or a 400 instead, and once the session is ready again everything works.
So the 500 is the symptom. The event that needs explaining is the renderer crash.
Two things about the reads that matter here
limit and offset do not reduce the load. I said this in my first reply and it is worth being blunt about, since you are relying on it. The gateway asks the browser for the entire address book and applies your window afterwards, in Node. Inside the page the read is a single command that walks every contact, awaits a business profile lookup for every business or enterprise entry, and serializes the whole array as one payload. A request with limit=50 does exactly the same work in the browser as one with no limit at all; only the response body is smaller. There is no way to page this today, and that is a real gap on our side, not something you can work around from the client.
getBlockedContacts is not the same shape. Its cost tracks the size of your blocklist, not your address book, so it is normally cheap. It appears in your log because it was in flight at the same moment, from a second concurrent request, not because it is expensive. Worth knowing all the same: nothing in the gateway serializes concurrent reads against one session's page, so two callers can have two page reads running on one renderer at once.
What would place the crash
The contact count is the number that decides whether this is a size problem, and I still do not have it. Alongside it:
- Roughly how many contacts are on that account, and roughly how many are WhatsApp Business accounts.
docker statsfor the container while a contacts read is running, and themem_limitin your compose file. The shipped default is 2 GiB, a whatsapp-web.js session costs roughly 300 to 500 MB before any read, and your log shows at least two sessions on that container.- Whether you set
PUPPETEER_ARGSto anything. If you did, it replaces the default flag set completely, including--disable-dev-shm-usage, which is the flag that keeps Chromium from crashing on Docker's small shared memory mount. A partial setting drops it silently.
About PUPPETEER_PROTOCOL_TIMEOUT_MS
Your latest log still shows the contacts read surfacing as a raw TargetCloseError through ExceptionsHandler. That is the code path as it stood before 30 August; main now converts it to a 503. So the build you are running predates that change.
That matters for the workaround. If you are on 0.23.3 as the report says, no code in that tag reads PUPPETEER_PROTOCOL_TIMEOUT_MS, so the variable has had no effect on your deployment at all and the improvement you saw after setting it came from something else. Please confirm the tag or commit you built from, so I know which of these failures you have actually been hitting.
What changes, and when
Both halves of your log are now fixed on main, and both reach you in the next release:
GET /contactsanswering 500 on a dead page was fixed in #1478.GET /contacts/blockedstill answered 500 even though the route documents 503. #1521 fixes that, along with the same gap on the number lookup, the addressbook save and delete, and block and unblock. Four of those had no error handling on that path at all, so a dead page there was not even reported to the liveness check.
Chasing it turned up the same defect in fifteen more whatsapp-web.js operations, fixed in #1525: the group list and membership queue, the label reads and writes, and nine message operations. Twelve of those had no handling on that path either. One is worth pointing out to you specifically, GET /messages/{chatId}/history, since it is the other large read you are likely to make and it had exactly the same problem.
To be clear about what that does and does not buy you: it makes the failure honest, so a client can tell "the browser died, retry shortly" from "the gateway broke". It does not stop the browser dying.
Two changes would actually reduce that, and neither is written yet. The first is making the read much smaller: the gateway keeps six fields per contact out of the twenty or so it currently pulls out of the page, so most of what that read costs is discarded on arrival. The second is making concurrent reads on one page take turns, which nothing does today. The crash you hit is a different mechanism from #1501, so neither issue covers this yet; I will keep it here rather than open a third.
Following up on the two reductions I said would actually help the renderer crash, not just make the failure honest.
The first one is now written: #1535 makes the page-side contact read much smaller. Instead of client.getContacts() pulling the full ~20-field object per contact and awaiting a business-profile lookup for every business entry, it walks the store in-page and returns only the six fields we keep, skipping the discarded BusinessProfile.find entirely. It also yields to the page event loop every 256 contacts, so a large read no longer holds the renderer thread in one uninterrupted stretch (that was the separate #1501 starvation, but the smaller read is exactly the reduction I described here). It lands in the next release.
The 500 -> 503 honesty fixes (#1478, #1521, #1525) also ship in that release, so GET /contacts and the other page reads will report a dead renderer as a retryable 503 rather than a bare 500.
The second reduction, serializing concurrent reads so two callers do not run two page reads on one renderer at once, is still not written. I am keeping this issue for it.
What is still open is the crash itself. #1535 lowers the cost of the read, but it does not by itself explain a renderer dying, and the numbers that would place that are the ones I am still missing: roughly how many contacts (and how many Business accounts) are on that session, docker stats and the mem_limit while a read runs, whether PUPPETEER_ARGS is set (it replaces the whole default flag set, including --disable-dev-shm-usage), and the exact tag or commit you built from. On 0.23.3, PUPPETEER_PROTOCOL_TIMEOUT_MS is not read at all, so confirming the build tells me which failure you are actually hitting.
Closing: both layers behind this 500 shipped in v0.23.4. PUPPETEER_PROTOCOL_TIMEOUT_MS covers the protocol-timeout read, and #1535 stops a long contacts read from starving the liveness probe, so the watchdog no longer tears down a healthy session mid-read (the mechanism filed as #1501). Upgrade and the route should answer; if the 500 still appears on 0.23.4, reopen with the surrounding log.