discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

`ws` throws `TypeError: Cannot use 'in' operator to search for 'code' in undefined` when with Deno

Open NeuroWhAI opened this issue 3 weeks ago • 6 comments

Which package is this bug report for?

ws

Issue description

  1. Use deno, Make a simple Discord bot.
  2. Leave the bot running for a long time. (Maybe 1 day?)
  3. The bot suddenly throws an error and dies.

Error : TypeError: Cannot use 'in' operator to search for 'code' in undefined Location: https://github.com/discordjs/discord.js/blob/main/packages/ws/src/ws/WebSocketShard.ts#L794

If I manually modify the conditional statement locally as follows, the problem no longer occurs. But I'm not sure if it's okay to do this.

onError(error) {
  if (error && "code" in error && ["ECONNRESET", "ECONNREFUSED"].includes(error.code)) {

I'm not sure if this is due to differences between Deno and Node.js, but I suspect it is.

Code sample

No response

Versions

  • discord.js 14.15.3
  • Deno 1.44.0

Issue priority

Low (slightly annoying)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMessages, MessageContent

I have tested this issue on a development release

No response

NeuroWhAI avatar Jun 06 '24 06:06 NeuroWhAI