WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3k stars 1.03k forks source link

[BUG] Cannot read properties of undefined (reading 'includes') #771

Closed samuelrac closed 1 month ago

samuelrac commented 1 month ago

Baileys version: v6.7.2

Hello, I'm getting error below:

{
    "level": 50,
    "time": 1715174266948,
    "pid": 153,
    "hostname": "wpp-api-ipchat",
    "err": {
        "type": "TypeError",
        "message": "Cannot read properties of undefined (reading 'includes')",
        "stack": "TypeError: Cannot read properties of undefined (reading 'includes')\n    at shouldIgnoreJid (/home/node/app/Services/Baileys/Main.ts:112:63)\n    at handleReceipt (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/messages-recv.js:464:13)\n    at execTask (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/messages-recv.js:691:20)\n    at processNodeWithBuffer (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/messages-recv.js:688:15)\n    at WebSocketClient.<anonymous> (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/messages-recv.js:703:9)\n    at WebSocketClient.emit (node:events:390:28)\n    at /home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:236:35\n    at Object.decodeFrame (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Utils/noise-handler.js:136:17)\n    at WebSocketClient.onMessageReceived (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:212:15)\n    at WebSocketClient.emit (node:events:390:28)"
    },
    "msg": "unexpected error in 'handling receipt'"
}

But I don't know what's causing it because it's intermittent.

samuelrac commented 1 month ago

I noticed this error coming from my connection object:

shouldIgnoreJid: (jid) =>
      isJidBroadcast(jid) || isJidStatusBroadcast(jid) || jid.includes('newsletter'),

In some time this jid parameter comes undefined

bobslavtriev commented 1 month ago

Use:

shouldIgnoreJid: (jid) =>
    !jid || isJidBroadcast(jid) || jid.includes('newsletter'),

And if you are using isJidBroadcast(), there is no need to use isJidStatusBroadcast()

samuelrac commented 1 month ago

Use:

shouldIgnoreJid: (jid) =>
    !jid || isJidBroadcast(jid) || jid.includes('newsletter'),

And if you are using isJidBroadcast(), there is no need to use isJidStatusBroadcast()

Thanks for your response.