datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed #134

Closed ElBatou closed 3 years ago

ElBatou commented 3 years ago

Hi, I have multiple websites that are pulling info from one datocms source. Whenever I switch from website A to website, B, C, or D and try the command: gatsby develop I get the usual error of JavaScript out of memory:

`success createSchemaCustomization - 2.735s ⠦ source and transform nodes ⠦ loading DatoCMS content

<--- Last few GCs --->

[19277:0x60a3250] 92849 ms: Mark-sweep 2019.3 (2083.7) -> 2010.9 (2087.5) MB, 1977.9 / 0.0 ms (average mu = 0.147, current mu = 0.060) allocation failure scavenge might not succeed [19277:0x60a3250] 94814 ms: Mark-sweep 2023.2 (2087.5) -> 2014.8 (2091.2) MB, 1852.9 / 0.0 ms (average mu = 0.102, current mu = 0.057) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0xa2afd0 node::Abort() [/home/username/.nvm/versions/node/v14.3.0/bin/node] 2: 0x97a467 node::FatalError(char const, char const) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 3: 0xb9e04e v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 4: 0xb9e3c7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 5: 0xd3e7d5 [/home/username/.nvm/versions/node/v14.3.0/bin/node] 6: 0xd3f17b v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 7: 0xd4cf72 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 8: 0xd4ddc5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 9: 0xd5078c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 10: 0xd2546b v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::RootIndex, int, v8::internal::Object, v8::internal::AllocationType) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 11: 0xd25583 v8::internal::Handle v8::internal::Factory::NewFixedArrayWithMap(v8::internal::RootIndex, int, v8::internal::AllocationType) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 12: 0xf3824b v8::internal::HashTable<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::New(v8::internal::Isolate, int, v8::internal::AllocationType, v8::internal::MinimumCapacity) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 13: 0xf40e0d v8::internal::Dictionary<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::Add(v8::internal::Isolate, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::PropertyDetails, v8::internal::InternalIndex) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 14: 0xf4264a v8::internal::BaseNameDictionary<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::Add(v8::internal::Isolate, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::PropertyDetails, v8::internal::InternalIndex) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 15: 0x106544c v8::internal::Runtime_AddDictionaryProperty(int, unsigned long, v8::internal::Isolate*) [/home/username/.nvm/versions/node/v14.3.0/bin/node] 16: 0x13a9e39 [/home/username/.nvm/versions/node/v14.3.0/bin/node] Aborted (core dumped)`

If I run the build command for production after that error: gatsby build, the project compiles without errors. And if I try the command: gatsby develop again this time the website gets compiled without the initial error.

If I switch to a different website/project the problem repeats. Hope it makes sense, best regards!

matjack1 commented 3 years ago

hey @ElBatou looks like the same problem as this one: https://github.com/datocms/gatsby-source-datocms/issues/123 right?

pieh commented 3 years ago

(Just pasting same comment I made in #123)

This is in fact very likely gatsby core issue. I got my hand on one reproductions and was able to make some quick hanges in gatsby core to prevent this (for validation purposes - those changes need to be done properly and not in hacky way). In any case I opened https://github.com/gatsbyjs/gatsby/issues/28916 in gatsby repo to track this issue (as this is not Datocms specific issue)

pieh commented 3 years ago

Ok, found particular culrpint and workaround (at least until we ship it in stable gatsby). The extra memory usage (and actually cpu perf overhead) comes from http://bluebirdjs.com/docs/api/promise.longstacktraces.html in gatsby develop. If you run BLUEBIRD_LONG_STACK_TRACES=0 gatsby develop you should be able to not hit Out-of-memory fatal crash (or at least not because of the bluebird's long stack traces). I will be opening PR in gatsby project so disabling of those happens automatically, but until then using BLUEBIRD_LONG_STACK_TRACES=0 should unblock you

pieh commented 3 years ago

gatsby@2.30.2 was released that by default disables debug bluebird config and should fix OOM crashes for gatsby develop

stefanoverna commented 3 years ago

You're a hero! Thanks Michal!

— Stefano Verna

DatoCMS

--- original message --- On January 13, 2021, 12:42 PM GMT+1 notifications@github.com wrote:

gatsby@2.30.2 was released that by default disables debug bluebird config and should fix OOM crashes for gatsby develop

You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe. --- end of original message ---