In every ~10 days I get the error below and my app stops working. When visiting my website I get nginx 404 Page Not Found error instead of actual site. Then I do sudo service nginx restart or just restarting the server and it fix the issue again for ~10 days. Is this an issue with my javascript server code or nginx? Any help where to look please?

2020-06-14T05:58:36.095100579Z app[web.1]: <--- Last few GCs --->
2020-06-14T05:58:36.095112170Z app[web.1]: 
2020-06-14T05:58:36.095115838Z app[web.1]: [207:0x4d09090] 832640510 ms: Mark-sweep 487.2 (496.1) -> 486.2 (496.1) MB, 1144.7 / 0.0 ms  (average mu = 0.092, current mu = 0.007) allocation failure scavenge might not succeed
2020-06-14T05:58:36.095119550Z app[web.1]: [207:0x4d09090] 832641479 ms: Mark-sweep 487.0 (496.1) -> 486.2 (496.1) MB, 959.2 / 0.0 ms  (average mu = 0.057, current mu = 0.010) allocation failure scavenge might not succeed
2020-06-14T05:58:36.095123161Z app[web.1]: 
2020-06-14T05:58:36.095126001Z app[web.1]: 
2020-06-14T05:58:36.095128907Z app[web.1]: <--- JS stacktrace --->
2020-06-14T05:58:36.095134471Z app[web.1]: 
2020-06-14T05:58:36.095911054Z app[web.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2020-06-14T05:58:36.129446766Z app[web.1]:  1: 0xa2b020 node::Abort() [node]
2020-06-14T05:58:36.131107714Z app[web.1]:  2: 0x97a467 node::FatalError(char const*, char const*) [node]
2020-06-14T05:58:36.132804121Z app[web.1]:  3: 0xb9e0ee v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
2020-06-14T05:58:36.134401622Z app[web.1]:  4: 0xb9e467 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
2020-06-14T05:58:36.135093021Z app[web.1]:  5: 0xd3e875  [node]
2020-06-14T05:58:36.136541772Z app[web.1]:  6: 0xd3f21b v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
2020-06-14T05:58:36.137984071Z app[web.1]:  7: 0xd4d012 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
2020-06-14T05:58:36.138711400Z app[web.1]:  8: 0xd4de65 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
2020-06-14T05:58:36.139372930Z app[web.1]:  9: 0xd5082c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2020-06-14T05:58:36.140701052Z app[web.1]: 10: 0xd15e8a v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
2020-06-14T05:58:36.142199154Z app[web.1]: 11: 0xd13724 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
2020-06-14T05:58:36.143429875Z app[web.1]: 12: 0xd13c30 v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString(int, v8::internal::AllocationType) [node]
2020-06-14T05:58:36.144885109Z app[web.1]: 13: 0xf5ed0a v8::internal::String::SlowFlatten(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ConsString>, v8::internal::AllocationType) [node]
2020-06-14T05:58:36.146444827Z app[web.1]: 14: 0x10756db v8::internal::Runtime_RegExpExecMultiple(int, unsigned long*, v8::internal::Isolate*) [node]
2020-06-14T05:58:36.147370373Z app[web.1]: 15: 0x13a9ed9  [node]
2020-06-14T05:58:36.532496923Z app[web.1]: Aborted (core dumped)
2020-06-14T05:58:36.735898791Z app[web.1]: npm ERR! code ELIFECYCLE
2020-06-14T05:58:36.740914962Z app[web.1]: npm ERR! errno 134
2020-06-14T05:58:36.767312820Z app[web.1]: npm ERR! do-next@1.0.0 start: `NODE_ENV=production node server.js`
2020-06-14T05:58:36.767534181Z app[web.1]: npm ERR! Exit status 134
2020-06-14T05:58:36.767774113Z app[web.1]: npm ERR! 
2020-06-14T05:58:36.767945922Z app[web.1]: npm ERR! Failed at the do-next@1.0.0 start script.
2020-06-14T05:58:36.768117744Z app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-06-14T05:58:36.868753665Z app[web.1]: 
2020-06-14T05:58:36.869121544Z app[web.1]: npm ERR! A complete log of this run can be found in:
2020-06-14T05:58:36.869311174Z app[web.1]: npm ERR!     /app/.npm/_logs/2020-06-14T05_58_36_798Z-debug.log

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

I’m facing the same issues here too.

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory when running NODE_ENV=production npm run build

Help would be greatly appreciated!

Submit an Answer