Discord.js: invalid array length Allocation failed - JavaScript heap out of memory [PRESENCE_UPDATE]

Created on 13 Oct 2020  路  6Comments  路  Source: discordjs/discord.js

Hello, for a little while I have this error which crashes my bot every ~ 2 days. The presence cache seems to be overloaded which normally should not cause any problems because the bot is only on 500 servers.

<--- Last few GCs --->
[13555:0x2a95550] 213598262 ms: Scavenge 1550.6 (2219.0) -> 1540.6 (2219.0) MB, 24.3 / 0.0 ms  (average mu = 0.998, current mu = 0.998) allocation failure
[13555:0x2a95550] 213601947 ms: Scavenge 1555.7 (2219.0) -> 1545.7 (2219.0) MB, 23.7 / 0.0 ms  (average mu = 0.998, current mu = 0.998) allocation failure
[13555:0x2a95550] 213606266 ms: Scavenge 1560.7 (2219.0) -> 1550.8 (2219.0) MB, 23.8 / 0.0 ms  (average mu = 0.998, current mu = 0.998) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
    0: ExitFrame [pc: 0x134e879]
Security context: 0x213c9b380919 <JSObject>
    1: assign [0x213c9b381241](this=0x213c9b3809b1 <JSFunction Object (sfi = 0x3c4c27507b49)>,0x254525cd6131 <Object map = 0x302286a84059>,0x2f86787d1d29 <Object map = 0x302286a84559>)
    2: PRESENCE_UPDATE [0x1ef8587f2d79] [/root/bots/fgi/node_modules/discord.js/src/client/websocket/handlers/PRESENCE_UPDATE.js:~3] [pc=0xbf432c33288](this=0x113c4e7eaaf1 <Obje...
FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
 1: 0x9bcb80 node::Abort() [/usr/local/bin/node]
 2: 0x9bdd16 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0xb1948e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0xb19809 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0xcca1f5  [/usr/local/bin/node]
 6: 0xca7cb5 v8::internal::Factory::CopyWeakArrayListAndGrow(v8::internal::Handle<v8::internal::WeakArrayList>, int, v8::internal::AllocationType) [/usr/local/bin/node]
 7: 0xea601a v8::internal::WeakArrayList::EnsureSpace(v8::internal::Isolate*, v8::internal::Handle<v8::internal::WeakArrayList>, int, v8::internal::AllocationType) [/usr/local/bin/node]
 8: 0xea62b3 v8::internal::PrototypeUsers::Add(v8::internal::Isolate*, v8::internal::Handle<v8::internal::WeakArrayList>, v8::internal::Handle<v8::internal::Map>, int*) [/usr/local/bin/node]
 9: 0xe6a764 v8::internal::JSObject::LazyRegisterPrototypeUser(v8::internal::Handle<v8::internal::Map>, v8::internal::Isolate*) [/usr/local/bin/node]
10: 0xe93dd4 v8::internal::Map::GetOrCreatePrototypeChainValidityCell(v8::internal::Handle<v8::internal::Map>, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0xe89dcf v8::internal::LookupIterator::ApplyTransitionToDataProperty(v8::internal::Handle<v8::internal::JSReceiver>) [/usr/local/bin/node]
12: 0xebf8e1 v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::Maybe<v8::internal::ShouldThrow>, v8::internal::StoreOrigin) [/usr/local/bin/node]
13: 0xec04c7 v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) [/usr/local/bin/node]
14: 0xfe46d7 v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) [/usr/local/bin/node]
15: 0xe6cee7 v8::internal::JSReceiver::SetOrCopyDataProperties(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Object>, v8::internal::ScopedVector<v8::internal::Handle<v8::internal::Object> > const*, bool) [/usr/local/bin/node]
16: 0xfe7073 v8::internal::Runtime_SetDataProperties(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
17: 0x134e879  [/usr/local/bin/node]

Further details:

  • discord.js version: 12.3.1
  • Node.js version: 12.10.0
  • Operating system: Ubuntu

Relevant client options:

  • partials: none
  • gateway intents: none
  • other: none
unverified bug

All 6 comments

I run into the same issue, where presence cache seems to crash the bot every x hours.
My bot is in around 500 servers as well. And I'm looking for an alternative fix since I don't really use presence all that much. Besides when updating my own bot's presence or when fetching a user's presence through my profile command.

So hopefully someone has a potential "fix" or a solution.

https://discordjs.guide/popular-topics/intents use Gateway Intents, and don't supply the privilleged intent GUILD_PRESENCES, or use a machine with more memory

https://discordjs.guide/popular-topics/intents use Gateway Intents, and don't supply the privilleged intent GUILD_PRESENCES, or use a machine with more memory

The problem is that I cannot filter Intents, I do not have privileged access and therefore no more access to GUILD_MEMBERS and in terms of memory I have 16gb, I tried to increase the limit via --max-old-space-size but that did not solve the problem

The problem is that I cannot filter Intents, I do not have privileged access and therefore no more access to GUILD_MEMBERS

Is your bot verified but denied for the member intent? Later this week, Discord will disable access to privileged intents if you are not whitelisted or have not enabled them in the dev portal, even if you are not specifying intents in your code.

The problem is that I cannot filter Intents, I do not have privileged access and therefore no more access to GUILD_MEMBERS

Is your bot verified but denied for the member intent? Later this week, Discord will disable access to privileged intents if you are not whitelisted or have not enabled them in the dev portal, even if you are not specifying intents in your code.

while checking the bot, I skipped the chapter on privileged intents, a nice mistake .. but I just looked at the faq on the discord developers server and it is still possible to request them, so I will do it but unfortunately I need these two Intents.. so I can't turn them off to fix my problem

fixed by upgrading the node version to 12.19.0 .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shukriadams picture shukriadams  路  3Comments

tiritto picture tiritto  路  3Comments

Blumlaut picture Blumlaut  路  3Comments

Acaretia picture Acaretia  路  3Comments

iCrawl picture iCrawl  路  3Comments