The cause is authState.creds.me.name was not set yet by the time sendPresenceUpdate() is executed.
This is a problem when using markOnlineOnConnect: false because:
1) The user is seen as "Online" by other users.
2) Phone notifications are reduced e.g. phone doesn't vibrate on incoming messages.
To Reproduce
Steps to reproduce the behavior:
Update example.ts to use markOnlineOnConnect: false
This will be printed on the logs:
{"level":40,"time":"2024-06....","pid":37...,"hostname":"myHost","msg":"no name present, ignoring presence update request..."}
The user is seen as "Online" by other users.
Phone notifications are reduced e.g. phone doesn't vibrate on incoming messages.
Expected behavior
No error 40 on the logs
The user is NOT seen as "Online" by other users.
Phone notifications aren't affected, e.g. phone DOES vibrate on incoming messages.
Environment (please complete the following information):
Is this on a server?: no
What do your connectOptions look like? : The ones in the example plus markOnlineOnConnect: false
Do you have multiple clients on the same IP?: no
Are you using a proxy? : no
Additional context
Add any other context about the problem here.
Describe the bug
chat.ts
sendPresenceUpdate()
fails when connecting via QR https://github.com/WhiskeySockets/Baileys/blob/76d2a9d759c31e4b2346fb2f02ec572f4d4c0437/src/Socket/chats.ts#L544 This is printed on the logs:{"level":40,"time":"2024-06....","pid":37...,"hostname":"myHost","msg":"no name present, ignoring presence update request..."}
The cause is
authState.creds.me.name
was not set yet by the timesendPresenceUpdate()
is executed.This is a problem when using
markOnlineOnConnect: false
because: 1) The user is seen as "Online" by other users. 2) Phone notifications are reduced e.g. phone doesn't vibrate on incoming messages.To Reproduce Steps to reproduce the behavior:
example.ts
to usemarkOnlineOnConnect: false
example.ts
these lines:// await sock!.readMessages([msg.key])
// await sendMessageWTyping({ text: 'Hello there!' }, msg.key.remoteJid!)
{"level":40,"time":"2024-06....","pid":37...,"hostname":"myHost","msg":"no name present, ignoring presence update request..."}
Expected behavior
Environment (please complete the following information):
connectOptions
look like? : The ones in the example plusmarkOnlineOnConnect: false
Additional context Add any other context about the problem here.