Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It takes a very long time for messages to be sent to large chats #2727

Open
1 task done
thedeaddan opened this issue Jan 15, 2024 · 34 comments
Open
1 task done

It takes a very long time for messages to be sent to large chats #2727

thedeaddan opened this issue Jan 15, 2024 · 34 comments
Labels
bug Something isn't working

Comments

@thedeaddan
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When the bot forwards a message to a chat for ~700 people. That's a very high delay in sending. And an error often occurs:
[2024-01-15 13:32:37] error: Evaluation failed: Error: msg is not a media msg: unknown, isGif=false at e (https://web.whatsapp.com/:2:4911) at d (https://web.whatsapp.com/app.d61b42d11fedf617d4e8.js:269:59292) at t.getMsgMediaType (https://web.whatsapp.com/app.d61b42d11fedf617d4e8.js:269:57305) at https://web.whatsapp.com/app.d61b42d11fedf617d4e8.js:266:676147 at async Object.window.WWebJS.forwardMediaMessage (__puppeteer_evaluation_script__:308:16) at async Object.window.WWebJS.forwardMessage (__puppeteer_evaluation_script__:234:28) at async __puppeteer_evaluation_script__:7:20

Expected behavior

The forwarding speed should be higher

Steps to Reproduce the Bug or Issue

await msg.forward(msg.chat);

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

OS: Debian GNU/Linux 11 (bullseye) x86_64
Phone OS: Android 13
whatsapp-web.js version: v1.23.1-alpha.4
WhatsApp Web version: 2.2402.5
NodeJS ver: v20.9.0

Additional context

No response

@thedeaddan thedeaddan added the bug Something isn't working label Jan 15, 2024
@thedeaddan
Copy link
Author

The client's constant:

const client = new Client({
    authStrategy: new LocalAuth(),
    puppeteer: {
        executablePath: process.env.CHROME_EXECUTABLE_PATH,
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
        headless: 'new',
    }
});

@thedeaddan
Copy link
Author

I can also add that the system is used without a graphical shell (terminal only). If this is important, please let us know

@alechkos
Copy link
Collaborator

@thedeaddan
Do you use #2272?

@thedeaddan
Copy link
Author

@alechkos
yep

@alechkos
Copy link
Collaborator

@thedeaddan
Also please send your code

@alechkos
Copy link
Collaborator

@thedeaddan

That's a very high delay in sending

The delay is after each message or after you started the script and it is sending to 700 users and you can't use other funtion?

@alechkos
Copy link
Collaborator

alechkos commented Jan 15, 2024

@thedeaddan

yep

Do you use the updated pr version?

@thedeaddan
Copy link
Author

@pedroslopez Yes

@thedeaddan
Copy link
Author

@thedeaddan

That's a very high delay in sending

The delay is after each message or after you started the script and it is sending to 700 users and you can't use other funtion?

There is a delay in sending almost every message. It works in the following mode: It received a message from one chat for 500+ people and forwarded it to another chat for 700+ people. And vice versa

@thedeaddan
Copy link
Author

There is also a problem that if there are a lot of messages in the chat, let's say if it has been working for a long time. Then he just stops receiving them. Either it takes a very long time to receive, and it takes even longer to forward

@alechkos
Copy link
Collaborator

alechkos commented Feb 2, 2024

Already opened issues that maybe can help you: #1567, #2381

@thedeaddan
Copy link
Author

@alechkos
Unfortunately, it didn't help. I even changed the hosting to a more powerful one. 16 GB OF RAM. 150 GB NVMe. But it didn't help at all, over time he just can't forward. There is a feeling that it depends on the number of messages in the chats. I did the cleanup at startup. But it works for the first time, and then it freezes again

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan

Unfortunately, it didn't help.

Do you use https://github.com/pedroslopez/whatsapp-web.js/pull/2272?

yep

If you currently are using the forward method from the pr, then try to use an old one defined in the library, proceed npm i github:pedroslopez/whatsapp-web.js#main and check.

After it update if you have a problem with forwarding

@thedeaddan
Copy link
Author

thedeaddan commented Feb 4, 2024

@alechkos
When using this branch, forwarding falls into error:

/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: chat.forwardMessages is not a function
    at __puppeteer_evaluation_script__:5:31
    at ExecutionContext._evaluateInternal (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Message.forward (/root/wapp/node_modules/whatsapp-web.js/src/structures/Message.js:441:9)

Node.js v21.6.1

I am sending it using:

 await msg.forward(target_chat);

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan
Use this approach and then comment if it worked for you

@thedeaddan
Copy link
Author

@alechkos
So is it to overwrite the file after each update?

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

So is it to overwrite the file after each update?

No, just check it once

@thedeaddan
Copy link
Author

@alechkos

/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: window.Store.Chat.forwardMessagesToChats is not a function
    at __puppeteer_evaluation_script__:4:31
    at ExecutionContext._evaluateInternal (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Message.forward (/root/wapp/node_modules/whatsapp-web.js/src/structures/Message.js:441:9)

Node.js v21.6.1

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan
What wweb are you using? console.log(await client.getWWebVersion())

@thedeaddan
Copy link
Author

@alechkos
2.2405.4

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan
I have to check it

@thedeaddan
Copy link
Author

@alechkos
And for the rest, does message forwarding work normally, or is it not a popular method? Is there any other way?

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan

And for the rest, does message forwarding work normally, or is it not a popular method? Is there any other way?

Yes it works but in the pr

@thedeaddan
Copy link
Author

@thedeaddan

And for the rest, does message forwarding work normally, or is it not a popular method? Is there any other way?

Yes it works but in the pr

This is just a branch

npm install github:alechkos/whatsapp-web.js#forward-with-caption

?

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan
Yep

@thedeaddan
Copy link
Author

@alechkos
Yes, I am on this branch. I will try to do something for now. (Delete the original message after forwarding or clean the chat more often)

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan
In my pr I didn't implement the cache while forwarding media
if you are using my pr and you forward media then maybe this is the problem with slow forwarding

@thedeaddan
Copy link
Author

@alechkos And then what can I do?

@alechkos
Copy link
Collaborator

alechkos commented Feb 4, 2024

@thedeaddan

And then what can I do?

You can check the code and fix the implementation or to wait until I'll fix it
but firstly we have to check if the problem is with unimplemented cache

@thedeaddan
Copy link
Author

@alechkos
If anything, here are the client settings:

const client = new Client({
    authStrategy: new LocalAuth(),
    puppeteer: {
        executablePath: process.env.CHROME_EXECUTABLE_PATH,
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
        ignoreDefaultArgs: ['--disable-dev-shm-usage'], 
        ignoreHTTPSErrors: true,
        headless: 'new',
    }
});

@thedeaddan
Copy link
Author

@alechkos
Sometimes such errors also happen:

[2024-02-05 10:41:03] error: Evaluation failed: Error: msg is not a media msg: unknown, isGif=false
    at e (https://web.whatsapp.com/:2:4913)
    at d (https://web.whatsapp.com/app.f048d8d89717819d6c73.js:269:59333)
    at t.getMsgMediaType (https://web.whatsapp.com/app.f048d8d89717819d6c73.js:269:57346)
    at https://web.whatsapp.com/app.f048d8d89717819d6c73.js:266:682842
    at async Object.window.WWebJS.forwardMediaMessage (__puppeteer_evaluation_script__:308:16)
    at async Object.window.WWebJS.forwardMessage (__puppeteer_evaluation_script__:234:28)
    at async __puppeteer_evaluation_script__:7:20

image

@davalmeyda
Copy link

davalmeyda commented Feb 14, 2024

/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: window.Store.Chat.forwardMessagesToChats is not a function
    at __puppeteer_evaluation_script__:4:31
    at ExecutionContext._evaluateInternal (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Message.forward (/root/wapp/node_modules/whatsapp-web.js/src/structures/Message.js:441:9)

Node.js v21.6.1

I have the same problem, is there already a solution to this?

@thedeaddan
Copy link
Author

thedeaddan commented Feb 15, 2024

/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: window.Store.Chat.forwardMessagesToChats is not a function
    at __puppeteer_evaluation_script__:4:31
    at ExecutionContext._evaluateInternal (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/root/wapp/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async Message.forward (/root/wapp/node_modules/whatsapp-web.js/src/structures/Message.js:441:9)

Node.js v21.6.1

I have the same problem, is there already a solution to this?

npm install github:alechkos/whatsapp-web.js#forward-with-caption

But the work is still not stable, even on this branch. You have to constantly restart the script

@rbkayz
Copy link

rbkayz commented Mar 4, 2024

Did you figure out why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants