bun
bun copied to clipboard
TypeError: error is not an Object. (evaluating '"code" in error') in discord SDK when error happens
What version of Bun is running?
1.0.29+a146856d1
What platform is your computer?
Ubuntu
What steps can reproduce the bug?
use official discord sdk and get an error I use it like this:
import { Client, GatewayIntentBits } from 'discord.js'
const discordClient = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
})
discordClient.login(process.env.DISCORD_TOKEN)
What is the expected behavior?
error handling works inside the SDK
What do you see instead?
1043 | break;
1044 | }
1045 | }
1046 | }
1047 | onError(error) {
1048 | if ("code" in error && ["ECONNRESET", "ECONNREFUSED"].includes(error.code)) {
^
TypeError: error is not an Object. (evaluating '"code" in error')
at onError (/home/capaj/work-repos/brain-crypto-bot/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/ws/dist/index.js:1048:9)
at /home/capaj/work-repos/brain-crypto-bot/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/ws/dist/index.js:673:7
Additional information
I have the codebase in private github repo and will gladly share it with anyone from bun team.
Is there a more specific code example? I'm unable to reproduce this.
I hit this all the time with my discord bot on macOS Sonoma. I wrote my bot as a learning exercise for TypeScript, Discord, Websocket stuff. It's not really intended for anybody else to use but it is on GitHub: https://github.com/hippietrail/hippiebot.js Just run under node and disconnect from the WiFi and it'll soon crash like in the report. Under nodeJS it will wait for the network to come back.