Deployments crashes because of allocation problems!

This is the logs I am getting when trying to deploy a nestjs backend. I am using yarn.

yarn run v1.22.5
Jan 6 03:37:30 PM  $ nest start
Jan 6 03:38:59 PM  
Jan 6 03:38:59 PM  <--- Last few GCs --->
Jan 6 03:38:59 PM  
Jan 6 03:38:59 PM  [73:0x6a07790]   172601 ms: Mark-sweep (reduce) 252.8 (258.0) -> 252.0 (258.3) MB, 4005.7 / 0.0 ms  (average mu = 0.133, current mu = 0.025) allocation failure scavenge might not succeed
Jan 6 03:38:59 PM  [73:0x6a07790]   176894 ms: Mark-sweep (reduce) 253.4 (258.3) -> 252.2 (258.5) MB, 4098.5 / 0.0 ms  (average mu = 0.090, current mu = 0.045) allocation failure scavenge might not succeed
Jan 6 03:38:59 PM  
Jan 6 03:38:59 PM  
Jan 6 03:38:59 PM  <--- JS stacktrace --->
Jan 6 03:38:59 PM  
Jan 6 03:38:59 PM  FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Jan 6 03:38:59 PM   1: 0xb02930 node::Abort() [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   2: 0xa18149 node::FatalError(char const*, char const*) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   3: 0xcdd16e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   4: 0xcdd4e7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   5: 0xe94b55  [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   6: 0xe95636  [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   7: 0xea3b5e  [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   8: 0xea45a0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:38:59 PM   9: 0xea751e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:39:00 PM  10: 0xe68a5a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:39:00 PM  11: 0x11e17c6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:39:00 PM  12: 0x15d5439  [/opt/render/project/nodes/node-16.17.0/bin/node]
Jan 6 03:39:00 PM  Aborted (core dumped)
Jan 6 03:39:00 PM  error Command failed with exit code 134.
Jan 6 03:39:00 PM  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Hi Aymane,

The Command failed with exit code 134 seems to be a fairly common Node error. You should be able to resolve this with some changes to your build and/or start commands.

This article has a popular answer that might help point you in the right direction for additional trobuleshooting: https://stackoverflow.com/a/59572966

Regards,

Matt