waha icon indicating copy to clipboard operation
waha copied to clipboard

[WEBJS] - seeeions became starting , faild after a while starting

Open moneerAmr opened this issue 1 year ago • 9 comments

Describe the bug

after i link the whatsapp, it work and start fine , then after a while it is stack , the session appears start but the messages not send, when tried to restarting the session it not work just starting then fails. an error like this appeared.

{   "statusCode": 500,   "timestamp": "2025-06-21T18:45:05.520Z",   "exception": {     "stack": "TypeError: Cannot read properties of null (reading 'screenshot')\n    at WhatsappSessionWebJSPlus.getScreenshot (/app/dist/core/engines/webjs/session.webjs.core.js:320:56)\n    at ScreenshotController.screenshot (/app/dist/api/screenshot.controller.js:29:38)\n    at /app/node_modules/@nestjs/core/router/router-execution-context.js:38:29\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)",     "message": "Cannot read properties of null (reading 'screenshot')",     "name": "TypeError"   },   "request": {     "path": "/api/screenshot?session=Everest",     "method": "GET",     "query": {       "session": "Everest"     }   },   "version": {     "version": "2025.6.4",     "engine": "WEBJS",     "tier": "PLUS",     "browser": "/usr/bin/chromium"   }

I use the Waha pro , the latest version , WebJS, windows environment with docker. the config as below:

docker container create --name Whatsapp-apiNew -v /d/wa_sessions:/app/.sessions -p 3000:3000 --restart unless-stopped -e WHATSAPP_RESTART_ALL_SESSIONS=True -e WAHA_AUTO_START_DELAY_SECONDS=10 -e WAHA_PRINT_QR=False -e WHATSAPP_API_KEY=########### -e WHATSAPP_SWAGGER_ENABLED=false -e WHATSAPP_SWAGGER_USERNAME=##### -e WHATSAPP_SWAGGER_PASSWORD=###### -e WAHA_DASHBOARD_USERNAME=##### -e WAHA_DASHBOARD_PASSWORD= ####### -e WHATSAPP_DOWNLOAD_MEDIA=false  devlikeapro/waha-plus:latest

and this from docker log

[18:59:09.857] INFO (WebhookSender/7): session:Everest - Sending POST... {"reqId":305,"session":"Everest","id":"01JY9XQQX0BSTH52RDGDHS5810","event.id":"evt_01jy9xqqwncdf1zhydwkmx2jq6","url":"https://httpbin.org/post"}

[18:59:09.857] INFO (WhatsappSession/7): session:Everest - Job scheduled with timeout 2000 ms {"reqId":305,"session":"Everest","job":"start-engine","class":"SingleDelayedJobRunner"}

[18:59:10.019] INFO (WebhookSender/7): session:Everest - POST request was sent with status code: 200 {"reqId":305,"session":"Everest","id":"01JY9XQQX0BSTH52RDGDHS5810","event.id":"evt_01jy9xqqwncdf1zhydwkmx2jq6","url":"https://httpbin.org/post"}

[18:59:11.873] INFO (WebhookSender/7): session:Everest - Sending POST... {"reqId":305,"session":"Everest","id":"01JY9XQSW1GA2FYJQ7QBBWRECN","event.id":"evt_01jy9xqsvzebd8knhb6mbqxz1n","url":"https://httpbin.org/post"}

[18:59:11.873] INFO (WhatsappSession/7): session:Everest - Using cache type: 'none' {"reqId":305,"session":"Everest"}

[18:59:12.072] INFO (WebhookSender/7): session:Everest - POST request was sent with status code: 200 {"reqId":305,"session":"Everest","id":"01JY9XQSW1GA2FYJQ7QBBWRECN","event.id":"evt_01jy9xqsvzebd8knhb6mbqxz1n","url":"https://httpbin.org/post"}

[18:59:37.182] ERROR (WhatsappSession/7): session:Everest - Protocol error (Runtime.callFunctionOn): Execution context was destroyed. {"reqId":305,"session":"Everest"}

    err: {

      "type": "ProtocolError",

      "message": "Protocol error (Runtime.callFunctionOn): Execution context was destroyed.",

      "stack":

          ProtocolError: Protocol error (Runtime.callFunctionOn): Execution context was destroyed.

              at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:102:14)

              at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:106:16)

              at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:24:26)

              at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:99:26)

              at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:106:16)

              at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:24:26)

              at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:99:26)

              at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CdpSession.js:73: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:364:43)

              at CdpFrame. (/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:817:43)

              at WebjsClientPlus.inject (/app/node_modules/whatsapp-web.js/src/Client.js:107:55)

              at async WebjsClientPlus.initialize (/app/node_modules/whatsapp-web.js/src/Client.js:329:9)

              at async WebjsClientPlus.initialize (/app/dist/core/engines/webjs/WebjsClientCore.js:26:24)

      "name": "ProtocolError"

    }

please note this problem repeated many times at the day with differents sessions 

moneerAmr avatar Jun 21 '25 19:06 moneerAmr

Hi! What help with that issue, only logout and scanning new QR code for that session, right?

patron:PRO

devlikepro avatar Jun 23 '25 10:06 devlikepro

It repeated many time on the day, I made it for customer and I can not keep call him to log out and re login. I made work around by get copy of the sessions and when this happen I delete the session and bringe the backup. Put this is not a sloution !!!!

moneerAmr avatar Jun 23 '25 10:06 moneerAmr

Interesting, does the session restart help in this case or it goes to STARTING=>FAILED loop again? Looks like some chrome process is holding some lock may be if restoring from backup helps🤔

patron:PRO

devlikepro avatar Jun 23 '25 10:06 devlikepro

As you mention, the restart of session gave STARTING=>FAILED loop. I am agree with you I thougth also it is for some process is holding. by the way I use the default chromium

moneerAmr avatar Jun 23 '25 11:06 moneerAmr

could be related https://github.com/devlikeapro/waha/issues/1043

patron:PRO

devlikepro avatar Jun 24 '25 07:06 devlikepro

@moneerAmr no proxy used?

patron:PRO

devlikepro avatar Jun 24 '25 07:06 devlikepro

There are no proxy at all, this is the configuration for the image

docker container create --name Whatsapp-apiNew -v /d/wa_sessions:/app/.sessions -p 3000:3000 --restart unless-stopped -e WHATSAPP_RESTART_ALL_SESSIONS=True -e WAHA_AUTO_START_DELAY_SECONDS=10 -e WAHA_PRINT_QR=False -e WHATSAPP_API_KEY=########### -e WHATSAPP_SWAGGER_ENABLED=false -e WHATSAPP_SWAGGER_USERNAME=##### -e WHATSAPP_SWAGGER_PASSWORD=###### -e WAHA_DASHBOARD_USERNAME=##### -e WAHA_DASHBOARD_PASSWORD= ####### -e WHATSAPP_DOWNLOAD_MEDIA=false devlikeapro/waha-plus:lates

moneerAmr avatar Jun 24 '25 08:06 moneerAmr

When I tracked what happened I discoverd that the files here in this folder deleted ( around 450 files) D:\wa_sessions\webjs####\session-####\Default\IndexedDB\https_web.whatsapp.com_0.indexeddb.leveldb and only 8 files remain. and when I recopy this files from the backup folder the session back to work, then stack after a while

moneerAmr avatar Jul 02 '25 14:07 moneerAmr

looks like it removes auth files because it thinks the session got unauthorized, interesting, we'll check that! 🤔 👍

patron:PRO

devlikepro avatar Jul 03 '25 09:07 devlikepro