devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
831 stars 254 forks source link

error Command failed with exit code 1. #193

Closed dv336699 closed 10 months ago

dv336699 commented 10 months ago

I have just updated to WAHA Plus to make sure it was an issue with the version, so I'm using the latest version as at today. I'm using WAHA Plus with Docker.

Yesterday all of my sessions have stopped working.

Whenever I try to stop a session, I get the following error

whatsapp-http-api-plus  | [Nest] 34  - 09/01/2023, 8:02:36 AM     LOG [SessionManager] Stopping 7e6f6f2d-dc03-476f-b34a-1825962630c9 session...
whatsapp-http-api-plus  | [Nest] 34  - 09/01/2023, 8:02:36 AM     LOG [SessionManager] "7e6f6f2d-dc03-476f-b34a-1825962630c9" has been stopped.
whatsapp-http-api-plus  | node:events:492
whatsapp-http-api-plus  |       throw er; // Unhandled 'error' event
whatsapp-http-api-plus  |       ^
whatsapp-http-api-plus  |
whatsapp-http-api-plus  | Error: WebSocket was closed before the connection was established
whatsapp-http-api-plus  |     at WebSocket.close (/app/node_modules/ws/lib/websocket.js:285:7)
whatsapp-http-api-plus  |     at WebSocketClient.close (/app/node_modules/@adiwajshing/baileys/lib/Socket/Client/web-socket-client.js:53:21)
whatsapp-http-api-plus  |     at WhatsappSessionNoWebPlus.stop (/app/dist/core/session.noweb.core.js:131:22)
whatsapp-http-api-plus  |     at SessionManagerPlus.stop (/app/dist/plus/manager.plus.js:138:23)
whatsapp-http-api-plus  |     at SessionsController.stop (/app/dist/api/sessions.controller.js:32:28)
whatsapp-http-api-plus  |     at /app/node_modules/@nestjs/core/router/router-execution-context.js:38:29
whatsapp-http-api-plus  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
whatsapp-http-api-plus  |     at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
whatsapp-http-api-plus  |     at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17
whatsapp-http-api-plus  | Emitted 'error' event on WebSocketClient instance at:
whatsapp-http-api-plus  |     at WebSocket.<anonymous> (/app/node_modules/@adiwajshing/baileys/lib/Socket/Client/web-socket-client.js:46:100)
whatsapp-http-api-plus  |     at WebSocket.emit (node:events:514:28)
whatsapp-http-api-plus  |     at WebSocket.emit (node:domain:489:12)
whatsapp-http-api-plus  |     at emitErrorAndClose (/app/node_modules/ws/lib/websocket.js:1008:13)
whatsapp-http-api-plus  |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
whatsapp-http-api-plus  |
whatsapp-http-api-plus  | Node.js v20.5.1
whatsapp-http-api-plus  | error Command failed with exit code 1.
whatsapp-http-api-plus  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
whatsapp-http-api-plus exited with code 0
allburov commented 10 months ago

Hi! Have you tried to logout from a session and scan QR again?

dv336699 commented 10 months ago

@allburov Sorry I didn't make myself clear at first, the server crash when I try to call http://127.0.0.1:3000/api/sessions/stop

allburov commented 10 months ago

Got it, could you try to use POST /api/sessions/logout instead? It by passes some checks and logout session immediately. The flow would be

  1. /logout
  2. Restart container
  3. Start session, scan QR Send logs here if it didn't help!
dv336699 commented 10 months ago

@allburov I managed to reproduce the bug.

  1. start the container
  2. send the command to start a session (do not scan the qr code)
  3. send a command to stop the session
  4. the container will crash with
whatsapp-http-api-plus  | node:events:492
whatsapp-http-api-plus  |       throw er; // Unhandled 'error' event
whatsapp-http-api-plus  |       ^
whatsapp-http-api-plus  |
whatsapp-http-api-plus  | Error: WebSocket was closed before the connection was established
whatsapp-http-api-plus  |     at WebSocket.close (/app/node_modules/ws/lib/websocket.js:285:7)
whatsapp-http-api-plus  |     at WebSocketClient.close (/app/node_modules/@adiwajshing/baileys/lib/Socket/Client/web-socket-client.js:53:21)
whatsapp-http-api-plus  |     at WhatsappSessionNoWebPlus.stop (/app/dist/core/session.noweb.core.js:131:22)
whatsapp-http-api-plus  |     at SessionManagerPlus.stop (/app/dist/plus/manager.plus.js:138:23)
whatsapp-http-api-plus  |     at SessionsController.stop (/app/dist/api/sessions.controller.js:32:28)
whatsapp-http-api-plus  |     at /app/node_modules/@nestjs/core/router/router-execution-context.js:38:29
whatsapp-http-api-plus  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
whatsapp-http-api-plus  |     at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
whatsapp-http-api-plus  |     at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17
whatsapp-http-api-plus  | Emitted 'error' event on WebSocketClient instance at:
whatsapp-http-api-plus  |     at WebSocket.<anonymous> (/app/node_modules/@adiwajshing/baileys/lib/Socket/Client/web-socket-client.js:46:100)
whatsapp-http-api-plus  |     at WebSocket.emit (node:events:514:28)
whatsapp-http-api-plus  |     at WebSocket.emit (node:domain:489:12)
whatsapp-http-api-plus  |     at emitErrorAndClose (/app/node_modules/ws/lib/websocket.js:1008:13)
whatsapp-http-api-plus  |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
whatsapp-http-api-plus  |
whatsapp-http-api-plus  | Node.js v20.5.1
whatsapp-http-api-plus  |
whatsapp-http-api-plus  | error Command failed with exit code 1.
whatsapp-http-api-plus  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
whatsapp-http-api-plus exited with code 1
allburov commented 10 months ago

Got it, thank you for the detailed steps, we'll look at this!

allburov commented 10 months ago

Weird, this what happened with my session when I stop it before scanning QR code

[Nest] 54081  - 09/03/2023, 5:50:17 PM     LOG [SessionManager] Stopping default session...
[Nest] 54081  - 09/03/2023, 5:50:17 PM     LOG [SessionManager] "default" has been stopped.
dv336699 commented 10 months ago

Thanks for looking into this I have uploaded another fresh container and it seems to be working as expected, on the other server I had this issue, there were about 40 sessions, it could be a corrupted file or something, if it happens again, I'll let you know.

Thanks