Open Larsundso opened 2 years ago
Can replicate, even with d1ec8c37ffb7fe3b63eaa8c382f22ca1fb348c9b
Was going to say this is a duplicate, but I actually cannot find an open issue on this despite having discussed it with a maintainer before.
What was going on before is that, for large payloads, node-fetch's Response#clone()
that was being used would actually end up causing the surpassing of the default highWaterMark
, which causes underlying calls to methods such as json
that consume the response body to never resolve, and therefore your API calls to never resolve. You can read about that here.
Now, with the introduction of undici, the clone call was instead changed to { ...res }
, and I'm not particularly familiar with the behavior and intricacies of doing that, but I assume it's a similar underlying issue.
Spreading into an empty object does a shallow clone. However, undici's Dispatcher.ResponseData
(res) has a private symbol property that exposes the underlying stream, which is probably causing the same issue. Both node-fetch
and undici.request
rest implementation make use of node's streams under the hood, so it's safe to assume they'd both have the same bugs.
Which package is this bug report for?
discord.js
Issue description
TOKEN
(I tested it on 3 Guilds with 60k, 50k and 50 Members. Bug only appears on Large Servers)
GUILD_ID_OF_LARGE_GUILD
Listening to
<client>.rest.on('response', () => {})
breaks<guild>.bans.fetch()
and<guild>.invites.fetch()
Code sample
Package version
discord.js@14.0.0-dev.1651493371-4ba0f56
Node.js version
v17.5.0
Operating system
Windows 11 Enterprise (64 Bit) & Ubuntu 20.04 (64 Bit)
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildBans, GuildInvites
I have tested this issue on a development release
4ba0f56