Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

usync: status-protocol being undefined

Open AliAryanTech opened this issue 1 year ago • 13 comments

Screenshot 2025-04-11 032728

it was getting undefined for some users

AliAryanTech avatar Apr 10 '25 22:04 AliAryanTech

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@AliAryanTech/Baileys#patch-1
# YARN v2
yarn add @whiskeysockets/baileys@AliAryanTech/Baileys#patch-1

whiskeysockets-bot avatar Apr 10 '25 22:04 whiskeysockets-bot

I see no difference in safely trying toString an undefined object, but it doesn't change the fact the object could still be undefined, just that Rajeh loves using the forbidden null assertion

ghost avatar Apr 11 '25 05:04 ghost

when dealing with string content, it's better to use ? to avoid runtime errors...

for me, this isn’t a critical issue, but it’s definitely a good suggestion..

we’re always open to suggestions for improvement.

azudindaem avatar Apr 12 '25 03:04 azudindaem

I see no difference in safely trying toString an undefined object, but it doesn't change the fact the object could still be undefined, just that Rajeh loves using the forbidden null assertion

This is not the case here, since the node is already vetted (the tag is defined, it is error free), there's literally no reason to use a question mark operator. Regardless, it is a good idea for code quality alone.

purpshell avatar Apr 17 '25 15:04 purpshell

This is not the case here, since the node is already vetted (the tag is defined, it is error free), there's literally no reason to use a question mark operator. Regardless, it is a good idea for code quality alone.

Understood

ghost avatar Apr 17 '25 17:04 ghost

I see no difference in safely trying toString an undefined object, but it doesn't change the fact the object could still be undefined, just that Rajeh loves using the forbidden null assertion

This is not the case here, since the node is already vetted (the tag is defined, it is error free), there's literally no reason to use a question mark operator. Regardless, it is a good idea for code quality alone.

It got undefined, You can see logs in screenshot. that's why we need to fix it

AliAryanTech avatar Apr 17 '25 23:04 AliAryanTech

It got undefined, You can see logs in screenshot. that's why we need to fix it

@AliAryanTech You seem not to understand, whether you use safely access the object or you don't, if the data is undefined it will be undefined, as @purpshell had already said, node is already vetted and for you to use the ? question mark operator will just there for code quality reasons

ghost avatar Apr 18 '25 17:04 ghost

image

The screenshot clearly shows a TypeError: Cannot read properties of undefined (reading 'toString'), which occurs because node or node.content is undefined at runtime, While the assumption is that node is vetted, this error demonstrates that it’s not guaranteed to be defined in all cases. Adding the optional chaining operator (?.) isn’t just for code quality.

it prevents this crash and ensures the code handles unexpected undefined values gracefully. I believe this fix is necessary for robustness, and the pull request should be accepted to avoid such runtime errors in the future. @purpshell @AstroX11

AliAryanTech avatar Apr 18 '25 21:04 AliAryanTech

@azudindaem approve it

AliAryanTech avatar Apr 22 '25 14:04 AliAryanTech

image

The screenshot clearly shows a TypeError: Cannot read properties of undefined (reading 'toString'), which occurs because node or node.content is undefined at runtime, While the assumption is that node is vetted, this error demonstrates that it’s not guaranteed to be defined in all cases. Adding the optional chaining operator (?.) isn’t just for code quality.

it prevents this crash and ensures the code handles unexpected undefined values gracefully. I believe this fix is necessary for robustness, and the pull request should be accepted to avoid such runtime errors in the future. @purpshell @AstroX11

Ok

ghost avatar Apr 22 '25 14:04 ghost

why it's not merge yet?

AliAryanTech avatar Apr 25 '25 22:04 AliAryanTech

This is not a critical issue..

azudindaem avatar Apr 26 '25 00:04 azudindaem

why it's not merge yet?

lol

ghost avatar Apr 26 '25 09:04 ghost