pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.62k stars 3.48k forks source link

WAstate, chromium crash aw snap #1465

Closed voidpack closed 7 months ago

voidpack commented 2 years ago

Is there an existing issue for this?

Describe the bug

when wastate repeat opening, pairing, connected it cause high cpu resource and then some pc/server which low resource will crash aw snap on chromium.

Expected behavior

1-2hours inactivity of chat sometimes wastate opening,pairing,connected especially on midnight 1am -4am

Steps to Reproduce the Bug or Issue

dont know how to reopening state it just happenned automatic. image

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

windows android wwebjs 1.16.6 wawebversion 2.2216.8 nodejs v13.14.0

Additional context

No response

islamelgaidi commented 2 years ago

happened to me ,need to log out and login again out of memory message appeared too

voidpack commented 2 years ago

happened to me ,need to log out and login again out of memory message appeared too

yeah some of my client always random happened, some 24hours - 2/3days, some random 4-12hours. some with low spec pc, some with server pc 16-32gb ram occur too.

TiNaR71 commented 2 years ago

I have a server with 128gb of ram and i9 processor, and even there it happens :) I had to make a handler that checks the status of the tab, and if it does not respond, restart the connection.

bugsbunch commented 2 years ago

I have a server with 128gb of ram and i9 processor, and even there it happens :) I had to make a handler that checks the status of the tab, and if it does not respond, restart the connection.

Can you show me your solution, pls? I'm facing the same problem

omarmyousef commented 1 year ago

I have a server with 128gb of ram and i9 processor, and even there it happens :) I had to make a handler that checks the status of the tab, and if it does not respond, restart the connection.

sharing your solution would help alot

ZeANi-SHILIX commented 1 year ago

Happens to me too. (I make also telegram bot to quick control the whatsapp bot) Screenshot_20220729-113054_Telegraph

islamelgaidi commented 1 year ago

i found the fix for this //delete the service worker fix the issue @pedroslopez @PurpShell

const { Client, Location, List, Buttons, LocalAuth } = require('./index');
var fs = require('fs');
const authStrategy = new LocalAuth(); 

var worker = `${authStrategy.dataPath}/session/Default/Service Worker`;
//delete the service worker fix the issue
if (fs.existsSync(worker)) {
    fs.rmSync(worker, { recursive: true });
}
const client = new Client({ authStrategy, puppeteer: { headless: true, args: ['--no-sandbox'] }, restartOnAuthFail: true, takeoverOnConflict: true, takeoverTimeoutMs: 10 });
TasseDeCafe commented 1 year ago

I have a server with 128gb of ram and i9 processor, and even there it happens :) I had to make a handler that checks the status of the tab, and if it does not respond, restart the connection.

I'd also be curious to see your solution to this.

PurpShell commented 1 year ago

i found the fix for this //delete the service worker fix the issue @pedroslopez @PurpShell

const { Client, Location, List, Buttons, LocalAuth } = require('./index');
var fs = require('fs');
const authStrategy = new LocalAuth(); 

var worker = `${authStrategy.dataPath}/session/Default/Service Worker`;
//delete the service worker fix the issue
if (fs.existsSync(worker)) {
    fs.rmSync(worker, { recursive: true });
}
const client = new Client({ authStrategy, puppeteer: { headless: true, args: ['--no-sandbox'] }, restartOnAuthFail: true, takeoverOnConflict: true, takeoverTimeoutMs: 10 });

Thing is we already do this behind the curtains

We stop the workers gracefully instead of deleting them but ok

bernardoely commented 1 year ago

i found the fix for this //delete the service worker fix the issue @pedroslopez @PurpShell

const { Client, Location, List, Buttons, LocalAuth } = require('./index');
var fs = require('fs');
const authStrategy = new LocalAuth(); 

var worker = `${authStrategy.dataPath}/session/Default/Service Worker`;
//delete the service worker fix the issue
if (fs.existsSync(worker)) {
    fs.rmSync(worker, { recursive: true });
}
const client = new Client({ authStrategy, puppeteer: { headless: true, args: ['--no-sandbox'] }, restartOnAuthFail: true, takeoverOnConflict: true, takeoverTimeoutMs: 10 });

Thing is we already do this behind the curtains

We stop the workers gracefully instead of deleting them but ok

I am having issues of high CPU usage and will try this. Thanks!

bernardoely commented 1 year ago

Forgot to mention my client is dying when this happens:

image

voidpack commented 1 year ago

Forgot to mention my client is dying when this happens:

image

yes this is cause by wastate reconnecting (because of connection problem to server whatsapp) it cause high cpu on chromium using more than 8gb ram and then cause snap cannot reload page.

actually i already fix this issue on june but using custom client (old client base on purpshell latest md) also i'm not using authstrategy (still local path base on purpshell client) and the last step downgrade puppeteer using v10.4.0 and voila no more crash no more snap. run smooth almost 2 month nonstop without snap/crash

bugsbunch commented 1 year ago

Forgot to mention my client is dying when this happens: image

yes this is cause by wastate reconnecting (because of connection problem to server whatsapp) it cause high cpu on chromium using more than 8gb ram and then cause snap cannot reload page.

actually i already fix this issue on june but using custom client (old client base on purpshell latest md) also i'm not using authstrategy (still local path base on purpshell client) and the last step downgrade puppeteer using v10.4.0 and voila no more crash no more snap. run smooth almost 2 month nonstop without snap/crash

Sory, but what is a purpshell client? How to connect the local chromium profile folder on it?

voidpack commented 1 year ago

Forgot to mention my client is dying when this happens:

yes this is cause by wastate reconnecting (because of connection problem to server whatsapp) it cause high cpu on chromium using more than 8gb ram and then cause snap cannot reload page. actually i already fix this issue on june but using custom client (old client base on purpshell latest md) also i'm not using authstrategy (still local path base on purpshell client) and the last step downgrade puppeteer using v10.4.0 and voila no more crash no more snap. run smooth almost 2 month nonstop without snap/crash

Sory, but what is a purpshell client? How to connect the local chromium profile folder on it?

hi, this is my client.js file you can try use it (maybe you need a little custom on constant/injected file too) https://drive.google.com/file/d/1-Ym3mMs7OoGQxHHEIbUmSqpcTimWiMqF/view?usp=sharing

also on index.js file just add this (not using authstrategy) const client = new Client({ puppeteer: { headless: false , args:[ "--no-sandbox", ] }, clientId: 'wanode' });

bernardoely commented 1 year ago

also i'm not using authstrategy (still local path base on purpshell clien

Thank you will give it a try!

bugsbunch commented 1 year ago

Forgot to mention my client is dying when this happens:

yes this is cause by wastate reconnecting (because of connection problem to server whatsapp) it cause high cpu on chromium using more than 8gb ram and then cause snap cannot reload page. actually i already fix this issue on june but using custom client (old client base on purpshell latest md) also i'm not using authstrategy (still local path base on purpshell client) and the last step downgrade puppeteer using v10.4.0 and voila no more crash no more snap. run smooth almost 2 month nonstop without snap/crash

Sory, but what is a purpshell client? How to connect the local chromium profile folder on it?

hi, this is my client.js file you can try use it (maybe you need a little custom on constant/injected file too) https://drive.google.com/file/d/1-Ym3mMs7OoGQxHHEIbUmSqpcTimWiMqF/view?usp=sharing

also on index.js file just add this (not using authstrategy) const client = new Client({ puppeteer: { headless: false , args:[ "--no-sandbox", ] }, clientId: 'wanode' });

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

voidpack commented 1 year ago

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

i downgrade puppeteer using v10.4.0 so it was using chromium Version 93.0.4577.0

bernardoely commented 1 year ago

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

i downgrade puppeteer using v10.4.0 so it was using chromium Version 93.0.4577.0

Hi @voidpack. I've downgraded to v10.4.0 (using Chromium v93.0.4577.0) and used the indicated Client.js but I'm still getting the "Aw, Snap!" crash.

My WhatsApp instance is very heavy in chats and daily message volume.

Any tips are welcome!

bugsbunch commented 1 year ago

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

i downgrade puppeteer using v10.4.0 so it was using chromium Version 93.0.4577.0

Hi @voidpack. I've downgraded to v10.4.0 (using Chromium v93.0.4577.0) and used the indicated Client.js but I'm still getting the "Aw, Snap!" crash.

My WhatsApp instance is very heavy in chats and daily message volume.

Any tips are welcome!

me too

voidpack commented 1 year ago

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

i downgrade puppeteer using v10.4.0 so it was using chromium Version 93.0.4577.0

Hi @voidpack. I've downgraded to v10.4.0 (using Chromium v93.0.4577.0) and used the indicated Client.js but I'm still getting the "Aw, Snap!" crash.

My WhatsApp instance is very heavy in chats and daily message volume.

Any tips are welcome!

if you are using my client.js file, on index file new client still using authstrategy or not ? because authstrategy dont work with my client.js if not using it backup your file/respository first then try this old package.json (remove the package-lock.json first) https://drive.google.com/file/d/1vhwdIpFAXBCAO58Q_NoAoOe-zByRpVB7/view?usp=sharing (i'm suggest remove the node_modules folder too) then npm install. this is my last step using old package.json from pedro. after that a hundred client of mine never occur snap/crash again from june run nonstop 24hours.

bernardoely commented 1 year ago

We did exactly as you wrote, but it didn’t help :( What version of Chromium do you use? Could it be a browser issue?

i downgrade puppeteer using v10.4.0 so it was using chromium Version 93.0.4577.0

Hi @voidpack. I've downgraded to v10.4.0 (using Chromium v93.0.4577.0) and used the indicated Client.js but I'm still getting the "Aw, Snap!" crash. My WhatsApp instance is very heavy in chats and daily message volume. Any tips are welcome!

if you are using my client.js file, on index file new client still using authstrategy or not ? because authstrategy dont work with my client.js if not using it backup your file/respository first then try this old package.json (remove the package-lock.json first) https://drive.google.com/file/d/1vhwdIpFAXBCAO58Q_NoAoOe-zByRpVB7/view?usp=sharing (i'm suggest remove the node_modules folder too) then npm install. this is my last step using old package.json from pedro. after that a hundred client of mine never occur snap/crash again from june run nonstop 24hours.

Thanks for your reply.

When you say for me not to use authStrategy, do you mean removing the argument like below (where I commented the line)?

var client = new Client({ //authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-accelerated-2d-canvas', '--no-first-run', '--no-zygote', '--disable-gpu' ],}})

I see in your package.json you are pointing to puppeteer "^10.4.0" and not "10.4.0". This causes Chromium to go beyond v93 (goes to version 100.x). Can you confirm which version of Puppeteer and Chromium is running there?

My instance (which 6k chats) is running fine for a couple days with puppeteer 10.4.0 and Chromium 93.x, so the workaround helped indeed! But if I run a client.getChats() then chat.fetchMessages() a few times, I get the Aw Snap crash right away.

voidpack commented 1 year ago

Thanks for your reply.

When you say for me not to use authStrategy, do you mean removing the argument like below (where I commented the line)?

var client = new Client({ //authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-accelerated-2d-canvas', '--no-first-run', '--no-zygote', '--disable-gpu' ],}})

I see in your package.json you are pointing to puppeteer "^10.4.0" and not "10.4.0". This causes Chromium to go beyond v93 (goes to version 100.x). Can you confirm which version of Puppeteer and Chromium is running there?

My instance (which 6k chats) is running fine for a couple days with puppeteer 10.4.0 and Chromium 93.x, so the workaround helped indeed! But if I run a client.getChats() then chat.fetchMessages() a few times, I get the Aw Snap crash right away.

i'm still using puppeeter v10.4.0 (using Chromium v93.0.4577.0). maybe your 6000 chat have to many message to fetch ? if not important message maybe you can try clear all chat history(just clear not delete) from WA app on the phone. maybe it can help from aw snap for fetchMessage

bernardoely commented 1 year ago

Thanks for your reply. When you say for me not to use authStrategy, do you mean removing the argument like below (where I commented the line)? var client = new Client({ //authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-accelerated-2d-canvas', '--no-first-run', '--no-zygote', '--disable-gpu' ],}}) I see in your package.json you are pointing to puppeteer "^10.4.0" and not "10.4.0". This causes Chromium to go beyond v93 (goes to version 100.x). Can you confirm which version of Puppeteer and Chromium is running there? My instance (which 6k chats) is running fine for a couple days with puppeteer 10.4.0 and Chromium 93.x, so the workaround helped indeed! But if I run a client.getChats() then chat.fetchMessages() a few times, I get the Aw Snap crash right away.

i'm still using puppeeter v10.4.0 (using Chromium v93.0.4577.0). maybe your 6000 chat have to many message to fetch ? if not important message maybe you can try clear all chat history(just clear not delete) from WA app on the phone. maybe it can help from aw snap for fetchMessage

Thanks for your reply again and all of your support. The issue was that I was running a parallel iteration which was causing like 6k fetchmessages at the same time. Now my sync of chats is running a regular loop and all is fine!

I am using puppeeter v10.4.0 (using Chromium v93.0.4577.0) as well, based on your recommendation and now my instance takes like 3 days to crash instead of a couple hours, it's much better. Thank you so much. Cheers.

voidpack commented 1 year ago

Thanks for your reply. When you say for me not to use authStrategy, do you mean removing the argument like below (where I commented the line)? var client = new Client({ //authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-accelerated-2d-canvas', '--no-first-run', '--no-zygote', '--disable-gpu' ],}}) I see in your package.json you are pointing to puppeteer "^10.4.0" and not "10.4.0". This causes Chromium to go beyond v93 (goes to version 100.x). Can you confirm which version of Puppeteer and Chromium is running there? My instance (which 6k chats) is running fine for a couple days with puppeteer 10.4.0 and Chromium 93.x, so the workaround helped indeed! But if I run a client.getChats() then chat.fetchMessages() a few times, I get the Aw Snap crash right away.

i'm still using puppeeter v10.4.0 (using Chromium v93.0.4577.0). maybe your 6000 chat have to many message to fetch ? if not important message maybe you can try clear all chat history(just clear not delete) from WA app on the phone. maybe it can help from aw snap for fetchMessage

Thanks for your reply again and all of your support. The issue was that I was running a parallel iteration which was causing like 6k fetchmessages at the same time. Now my sync of chats is running a regular loop and all is fine!

I am using puppeeter v10.4.0 (using Chromium v93.0.4577.0) as well, based on your recommendation and now my instance takes like 3 days to crash instead of a couple hours, it's much better. Thank you so much. Cheers.

hai, that's great to hear your aw snap issue has been solve. it was nightmare for me too on late may till june when random a few hour and random clients have crash aw snap hahahahha. maybe my client not have 6k chat like your instance( i only have a few hundred chat) so i still have not found any crash aw snap again. cheers