FKLC / WhatsAppToDiscord

WhatsAppToDiscord is a Discord bot that uses WhatsApp Web as a bridge between Discord and WhatsApp.
https://fklc.github.io/WhatsAppToDiscord/
MIT License
238 stars 67 forks source link

Sending Stickers is causing the BOT to crash instantly #175

Closed Ishannaik closed 5 months ago

Ishannaik commented 6 months ago

Describe the bug Sending a sticker is causing my WA2DC to crash

To Reproduce Steps to reproduce the behavior:

  1. Send a sticker in a connected DM
  2. Only happens in some DMs and with a specific sticker
  3. See error

Heres the log file

{
  "level": 50,
  "time": 1703653100871,
  "pid": 699,
  "hostname": "d1454d92c06f",
  "version": "v0.10.22",
  "err": {
    "message": "Request failed with status code 403",
    "name": "AxiosError",
    "stack": "AxiosError: Request failed with status code 403\n    at settle (file:///home/runner/WA2DC/node_modules/axios/lib/core/settle.js:19:12)\n    at RedirectableRequest.handleResponse (file:///home/runner/WA2DC/node_modules/axios/lib/adapters/http.js:533:9)\n    at RedirectableRequest.emit (node:events:514:28)\n    at RedirectableRequest._processResponse (/home/runner/WA2DC/node_modules/follow-redirects/index.js:356:10)\n    at RedirectableRequest._onNativeResponse (/home/runner/WA2DC/node_modules/follow-redirects/index.js:62:10)\n    at Object.onceWrapper (node:events:629:26)\n    at ClientRequest.emit (node:events:514:28)\n    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)\n    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)\n    at TLSSocket.socketOnData (node:_http_client:535:22)",
    "config": {
      "transitional": {
        "silentJSONParsing": true,
        "forcedJSONParsing": true,
        "clarifyTimeoutError": false
      },
      "adapter": ["xhr", "http"],
      "transformRequest": [null],
      "transformResponse": [null],
      "timeout": 0,
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      "maxContentLength": null,
      "maxBodyLength": null,
      "env": {},
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "Origin": "https://web.whatsapp.com",
        "User-Agent": "axios/1.6.2",
        "Accept-Encoding": "gzip, compress, deflate, br"
      },
      "responseType": "stream",
      "method": "get",
      "url": "idk if this is sensitive so im removing this"
    },
    "code": "ERR_BAD_REQUEST",
    "status": 403
  },
  "msg": "Request failed with status code 403"
}
{
  "level": 30,
  "time": 1703653100872,
  "pid": 699,
  "hostname": "d1454d92c06f",
  "version": "v0.10.22",
  "msg": "Exiting!"
}

Adding a try and catch block to the index.js helped me fix the unwanted crashes

FKLC commented 6 months ago

Hmm unfortunately I can't reproduce this bug. I have quite a lot of stickers but none of them caused the bot to crash. It is also not clear on which line the bot crashes from the logs. So, unfortunately, I can't fix this bug from the logs and can't reproduce it. Sorry.

gabrielkeventx commented 5 months ago

I have the same problem.

I Wonder if there's a way to restart automatically when he crashes?

FKLC commented 5 months ago

I have the same problem.

I Wonder if there's a way to restart automatically when he crashes?

you can check platform/OS specific ways. It is different for windows/mac/ubuntu etc. it is not built in to the bot.