discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.34k stars 3.97k forks source link

Parent channel of thread has no thread manager #10563

Open Glazelf opened 3 hours ago

Glazelf commented 3 hours ago

Which package is this bug report for?

discord.js

Issue description

Bot "randomly" (not during boot cycle) crashes with error below: Schermafbeelding 2024-10-17 130011

Seems to be an issue with thread parent checks or something. I talked to @almostSouji about this problem here, for some context.

Note (souji): The issue is not reproduceable on reboot and happened only once during normal operation.

Code sample

No response

Versions

Issue priority

Low (slightly annoying)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildModeration, GuildMessages, GuildMessageReactions, DirectMessages, MessageContent

I have tested this issue on a development release

No response

almostSouji commented 3 hours ago

Seems to come from here: https://github.com/discordjs/discord.js/blob/0873f9a4c3a817ce9cf3821f713a871bc3902eb3/packages/discord.js/src/util/Channels.js#L67-L72

Which would imply a channel that does not have .threads (or another value) is being set as a parent (since the .parent seems to exist) at some point in time.

Potential causes could be a corrupted cache or a private thread being created on a somewhat rare channel type, which we have not considered yet.

almostSouji commented 3 hours ago

Looking at the partials, could this potentially be caused by the parent being partial? So we receive the partial parent and populate the cache with it; then the thread is being constructed and the partial parent does not have the .threads?