open-wa / wa-automate-docker

💬 🤖 The easiest way to turn your WhatsApp into an API. Be sure to 🌟 this repository for updates!
106 stars 31 forks source link

Incremental Memory #21

Closed NSOPORTEDESARROLLO closed 2 years ago

NSOPORTEDESARROLLO commented 2 years ago

Hi ,

I have some issues about memory, for example I have a VPS (4GB ram, 2 CPU cores), when I run a docker or local process memory ram starts about 400 mb, but after 5 days it is around 2GB. When memory reaches 100% api disconnects

Captura de Pantalla 2021-11-03 a la(s) 4 46 14 p  m Captura de Pantalla 2021-11-03 a la(s) 4 48 06 p  m

s

smashah commented 2 years ago

@NSOPORTEDESARROLLO try calling the /refresh endpoint to reduce ram usage from the browsers end. Please report back if that works for u

NSOPORTEDESARROLLO commented 2 years ago

I'm trying some like : curl -X POST http://localhost:8080/refresh, but I got:

{"success":false,"error":{"name":"Error","message":"Evaluation failed: TypeError: Cannot read properties of undefined (reading 'sendMessage')\n at puppeteer_evaluation_script:1:110364\n at puppeteer_evaluation_script:1:424734"}}

manojsitapara commented 2 years ago

@smashah I am also getting same error when I tried to use /refresh end point,

After 1-2 days docker container consuming 1.5 to 2 GB RAM

After restarting docker image, it uses around 400-500MB, but after 1-2 days it started consuming more memories.

{ "success": false, "error": { "name": "Error", "message": "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'sendMessage')\n at puppeteer_evaluation_script:1:115974\n at puppeteer_evaluation_script:1:449680" } }

Can you please help us to fix the issue?

smashah commented 2 years ago

I'm going to need to see all of your launch logs and config in order to replicate this error upon calling refresh.

manojsitapara commented 2 years ago

Here is my logs

  • QR code scanned. Loading session...
  • QR code scanned. Loading session...
  • Reinjecting api
  • WAPI Reinjected
  • Checking if session is valid
  • Downloading patches from https://cdn.openwa.dev/patches.json
  • Client is ready
  • Generating patch hash
  • Downloaded patches in 0.86s
  • Installing patches
  • Patches Installed: 80ece
  • Client loaded for normal account with 3085 contacts, 32 chats & 299 messages in 28.788s
  • Finalizing web session...
  • Finalizing client...
  • 🚀 @OPEN-WA ready for account: 3722
  • session_STARTUP
  • Setting Up API Explorer
  • API Explorer set up successfully
  • ...waiting for port 8080 to be free
  • Port 8080 is now free.
  • API Explorer (​http://localhost:8080/api-docs/ ​)

  • • Listening on port 8080!

  • • Listening on port 8080!

  • session_REFRESH
  • • Listening on port 8080!

  • Refreshing session
  • • Listening on port 8080!

  • Opening session in new tab
  • • Listening on port 8080!

  • Waiting for conflict to close stale tab...
  • • Listening on port 8080!

  • Checking if fresh session is authenticated...
  • • Listening on port 8080!

  • Injected new session...
  • • Listening on port 8080!

  • Downloading patches from https://cdn.openwa.dev/patches.json
  • • Listening on port 8080!

  • Generating patch hash
  • • Listening on port 8080!

  • Downloaded patches in 0.117s
  • • Listening on port 8080!

  • Installing patches middleware -> error Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'sendMessage') at puppeteer_evaluation_script:1:115974 at puppeteer_evaluation_script:1:449680 at ExecutionContext._evaluateInternal (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:175:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Promise.all (index 0) root@instance-1:/home/onlineshambhumate# Page down
smashah commented 2 years ago

@manojsitapara there is critical context in the logs at the beginning. Please share all of it not just after you scanned the qr code

smashah commented 2 years ago

@manojsitapara refresh is fixed in the :latest or :4.23.17

smashah commented 2 years ago

@NSOPORTEDESARROLLO

@manojsitapara refresh is fixed in the :latest or :4.23.17

manojsitapara commented 2 years ago

Thanks @smashah it is working now