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

Text messages gives error #2857

Closed
1 task done
bhejosms opened this issue Mar 31, 2024 · 17 comments
Closed
1 task done

Text messages gives error #2857

bhejosms opened this issue Mar 31, 2024 · 17 comments
Labels
bug Something isn't working

Comments

@bhejosms
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I try to send plain text message it gives error
(node:24580) UnhandledPromiseRejectionWarning: TypeError: Right-hand side of 'instanceof' is not an object
at Client.sendMessage (/home/Whatsapp/node_modules/whatsapp-web.js/src/Client.js:904:28)

where as media message with text works fine.

Expected behavior

Even only text message without media should go.

Steps to Reproduce the Bug or Issue

Try sending only text message

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

Linux

Additional context

No response

@bhejosms bhejosms added the bug Something isn't working label Mar 31, 2024
@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

hello,

Provide the code you are using to send this text message.

Are you using the same core found within main branch or you are using another fork or pull request?

Are you sending something related to polls ???

@bhejosms
Copy link
Author

Same code as of main branch.

Notinng related to poll.

It is just plain text message. Even only Hi gives same error.

@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

Same code as of main branch.

Notinng related to poll.

It is just plain text message. Even only Hi gives same error.

Provide the code part of how you are sending the text message

Also provide us with the node version you are using

As we see, the error is related about the type of content passed to the sendMessage method, it seems for any reason javascript fails to check if the passed value is instance of Poll class

So we need to see the code you use in order to see from where the error started

@AminaChouarfa
Copy link

AminaChouarfa commented Mar 31, 2024

does the project run normaly with you ?
cz for me i cant use the project since a week ago.

@bhejosms
Copy link
Author

bhejosms commented Mar 31, 2024 via email

@AminaChouarfa
Copy link

from any country plz?

@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

does the project run normaly with you ? cz for me i cant use the project since a week ago.

Which web whatsapp version you are using ????

@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

does the project run normaly with you ? cz for me i cant use the project since a week ago.

What are the issues you are encountering ???

If you are encountering the issue that prevent you to preserve session after rerun, so please read more on this here :
#2856

@bhejosms
Copy link
Author

Same code as of main branch.
Notinng related to poll.
It is just plain text message. Even only Hi gives same error.

Provide the code part of how you are sending the text message

Also provide us with the node version you are using

As we see, the error is related about the type of content passed to the sendMessage method, it seems for any reason javascript fails to check if the passed value is instance of Poll class

So we need to see the code you use in order to see from where the error started

client.sendMessage(fields.to + '@c.us', String(fields.message), {
linkPreview: true,
})
.then(function (result) {
console.log(result)
console.log("\n\n\n\n\n")

                res.end(result.id.id)
              })

@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

does the project run normaly with you ? cz for me i cant use the project since a week ago.

If you are usin web whatsapp 2.3 and you are encountering crash for first run (directly after scanning the qr code)

So take look to following PRs:
#2816
#2822
#2825
#2827

And stay up to date with PRs and issues to know what is going on with new version

@MoudiZd
Copy link

MoudiZd commented Mar 31, 2024

Same code as of main branch.
Notinng related to poll.
It is just plain text message. Even only Hi gives same error.

Provide the code part of how you are sending the text message
Also provide us with the node version you are using
As we see, the error is related about the type of content passed to the sendMessage method, it seems for any reason javascript fails to check if the passed value is instance of Poll class
So we need to see the code you use in order to see from where the error started

client.sendMessage(fields.to + '@c.us', String(fields.message), { linkPreview: true, }) .then(function (result) { console.log(result) console.log("\n\n\n\n\n")

                res.end(result.id.id)
              })

Before sending the message,
Check the type of fields.message
console.log(typeof fields.message);

Also check out the type of the intermediate value resulted from String Casting
console.log(typeof String(fields.message));

And tell the result

@bhejosms
Copy link
Author

bhejosms commented Apr 1, 2024 via email

@MoudiZd
Copy link

MoudiZd commented Apr 1, 2024

typeof fields.message = object typeof String(fields.message) = string

On Sun, Mar 31, 2024 at 7:01 PM MoudiZd @.> wrote: Same code as of main branch. Notinng related to poll. It is just plain text message. Even only Hi gives same error. Provide the code part of how you are sending the text message Also provide us with the node version you are using As we see, the error is related about the type of content passed to the sendMessage method, it seems for any reason javascript fails to check if the passed value is instance of Poll class So we need to see the code you use in order to see from where the error started client.sendMessage(fields.to + @.', String(fields.message), { linkPreview: true, }) .then(function (result) { console.log(result) console.log("\n\n\n\n\n") res.end(result.id.id) }) Before sending the messagw, Check the type of fields.message console.log(typeof fields.message); Also check out the type of the intermediate value resulted from String Casting console.log(typeof String(fields.message)); And tell the result — Reply to this email directly, view it on GitHub <#2857 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOX7DSCC3OCYDEP7W26QSDY3AFZPAVCNFSM6AAAAABFQLKXEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYG42DAOJYGM . You are receiving this because you authored the thread.Message ID: @.***>

Which node version

@MoudiZd
Copy link

MoudiZd commented Apr 1, 2024

Try to remove the third passed parameter, i see that you do not need this if you are sending a text message

I am talking about this:
{linkPreview: true}

@MoudiZd
Copy link

MoudiZd commented Apr 1, 2024

also add catch to the promise:

client.sendMessage(fields.to + '@c.us', String(fields.message)) 
.then(function (result) { 
console.log(result) console.log("\n\n\n\n\n")
res.end(result.id.id)
})
.catch(function(error){
console.log(error);
})

@bhejosms
Copy link
Author

bhejosms commented Apr 1, 2024 via email

@alechkos
Copy link
Collaborator

alechkos commented Apr 1, 2024

TypeError: Right-hand side of 'instanceof' is not an object
check your code, not a library bug

@alechkos alechkos closed this as completed Apr 1, 2024
Repository owner locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants