Nest: When deploy to heroku: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Created on 20 May 2020  路  5Comments  路  Source: nestjs/nest

Bug Report

Current behavior

I'm building a backend in Nestjs with Graphql (with subscriptions) and Mongo. When I start it locally it all works fine, but a soon as I deploy it to heroku it goes "from starting to crashed"

2020-05-20T20:13:05.837580+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-20T20:13:05.696858+00:00 app[web.1]:
2020-05-20T20:13:05.696867+00:00 app[web.1]: <--- Last few GCs --->
2020-05-20T20:13:05.696868+00:00 app[web.1]:
2020-05-20T20:13:05.696883+00:00 app[web.1]: [46:0x435ca70] 27708 ms: Mark-sweep 254.4 (256.8) -> 253.5 (256.8) MB, 292.6 / 0.0 ms (average mu = 0.225, current mu = 0.166) allocation failure scavenge might not succeed
2020-05-20T20:13:05.696883+00:00 app[web.1]: [46:0x435ca70] 27994 ms: Mark-sweep 254.4 (256.8) -> 253.2 (256.8) MB, 258.4 / 0.0 ms (average mu = 0.167, current mu = 0.096) allocation failure scavenge might not succeed
2020-05-20T20:13:05.696884+00:00 app[web.1]:
2020-05-20T20:13:05.696884+00:00 app[web.1]:
2020-05-20T20:13:05.696884+00:00 app[web.1]: <--- JS stacktrace --->
2020-05-20T20:13:05.696885+00:00 app[web.1]:
2020-05-20T20:13:05.696885+00:00 app[web.1]: ==== JS stack trace =========================================
2020-05-20T20:13:05.696886+00:00 app[web.1]:
2020-05-20T20:13:05.696886+00:00 app[web.1]: Security context: 0x2ce3f13008d1
2020-05-20T20:13:05.696887+00:00 app[web.1]: 0: builtin exit frame: captureStackTrace(this=0x2ce3f1301749 ,0x2ce3f1301749 2020-05-20T20:13:05.696887+00:00 app[web.1]:
2020-05-20T20:13:05.696888+00:00 app[web.1]: 1: handleErrorFromBinding(aka handleErrorFromBinding) [0xc6e0a539a09] [internal/fs/utils.js:229] [bytecode=0x2...
2020-05-20T20:13:05.696888+00:00 app[web.1]:
2020-05-20T20:13:05.696896+00:00 app[web.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2020-05-20T20:13:05.698061+00:00 app[web.1]: 1: 0xa09830 node::Abort() [node]
2020-05-20T20:13:05.698081+00:00 app[web.1]: 2: 0xa09c55 node::OnFatalError(char const, char const) [node]
2020-05-20T20:13:05.701635+00:00 app[web.1]: 3: 0xb7d71e v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [node]
2020-05-20T20:13:05.701637+00:00 app[web.1]: 4: 0xb7da99 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [node]
2020-05-20T20:13:05.701638+00:00 app[web.1]: 5: 0xd2a1f5 [node]
2020-05-20T20:13:05.701638+00:00 app[web.1]: 6: 0xd2a886 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
2020-05-20T20:13:05.701639+00:00 app[web.1]: 7: 0xd37105 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
2020-05-20T20:13:05.702629+00:00 app[web.1]: 8: 0xd37fb5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
2020-05-20T20:13:05.702630+00:00 app[web.1]: 9: 0xd3aa6c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2020-05-20T20:13:05.703089+00:00 app[web.1]: 10: 0xd02a67 v8::internal::Factory::NewFrameArray(int, v8::internal::AllocationType) [node]
2020-05-20T20:13:05.703713+00:00 app[web.1]: 11: 0xcd1608 [node]
2020-05-20T20:13:05.704349+00:00 app[web.1]: 12: 0xcd1ec3 v8::internal::Isolate::CaptureAndSetSimpleStackTrace(v8::internal::Handle, v8::internal::FrameSkipMode, v8::internal::Handle) [node]
2020-05-20T20:13:05.704949+00:00 app[web.1]: 13: 0xc1812d v8::internal::Builtin_ErrorCaptureStackTrace(int, unsigned long, v8::internal::Isolate) [node]
2020-05-20T20:13:05.705742+00:00 app[web.1]: 14: 0x13c5c79 [node]
2020-05-20T20:13:05.735032+00:00 app[web.1]: Aborted
2020-05-20T20:13:05.737831+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-20T20:13:05.738116+00:00 app[web.1]: npm ERR! errno 134
2020-05-20T20:13:05.739134+00:00 app[web.1]: npm ERR! [email protected] build: tsc -p tsconfig.build.json
2020-05-20T20:13:05.739225+00:00 app[web.1]: npm ERR! Exit status 134
2020-05-20T20:13:05.739420+00:00 app[web.1]: npm ERR!
2020-05-20T20:13:05.739559+00:00 app[web.1]: npm ERR! Failed at the [email protected] build script.
2020-05-20T20:13:05.739697+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-20T20:13:05.747295+00:00 app[web.1]:
2020-05-20T20:13:05.747513+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-20T20:13:05.747596+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-20T20_13_05_740Z-debug.log
2020-05-20T20:13:05.753640+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-20T20:13:05.753839+00:00 app[web.1]: npm ERR! errno 134
2020-05-20T20:13:05.754794+00:00 app[web.1]: npm ERR! [email protected] prestart:prod: rimraf dist && npm run build
2020-05-20T20:13:05.754875+00:00 app[web.1]: npm ERR! Exit status 134
2020-05-20T20:13:05.754984+00:00 app[web.1]: npm ERR!
2020-05-20T20:13:05.755072+00:00 app[web.1]: npm ERR! Failed at the [email protected] prestart:prod script.
2020-05-20T20:13:05.755153+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-20T20:13:05.761376+00:00 app[web.1]:
2020-05-20T20:13:05.761378+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-20T20:13:05.761379+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-20T20_13_05_755Z-debug.log

Expected behavior

Run it as in my local env and reach the service through /graphql endpoint.

Environment


Nest version: 6.0.0


For Tooling issues:
- Node version: 11.0.0
- Platform:  Mac OS Catalina 10.15.3

Others:

needs triage

All 5 comments

Looks like something in the build process is running out of memory. Are you able to provide a minimum reproduction?

I'm not sure what should I provide... A nestjs project with the set up as if I would deploy it to heroku?

TBH This doesn't seem to be related to NestJS but rather to your application & env configuration. We can't really help with the DevOps related stuff.

Please, use our Discord channel (support) or StackOverflow for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

Bug Report

Current behavior

I'm building a backend in Nestjs with Graphql (with subscriptions) and Mongo. When I start it locally it all works fine, but a soon as I deploy it to heroku it goes "from starting to crashed"

2020-05-20T20:13:05.837580+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-20T20:13:05.696858+00:00 app[web.1]:
2020-05-20T20:13:05.696867+00:00 app[web.1]: <--- Last few GCs --->
2020-05-20T20:13:05.696868+00:00 app[web.1]:
2020-05-20T20:13:05.696883+00:00 app[web.1]: [46:0x435ca70] 27708 ms: Mark-sweep 254.4 (256.8) -> 253.5 (256.8) MB, 292.6 / 0.0 ms (average mu = 0.225, current mu = 0.166) allocation failure scavenge might not succeed
2020-05-20T20:13:05.696883+00:00 app[web.1]: [46:0x435ca70] 27994 ms: Mark-sweep 254.4 (256.8) -> 253.2 (256.8) MB, 258.4 / 0.0 ms (average mu = 0.167, current mu = 0.096) allocation failure scavenge might not succeed
2020-05-20T20:13:05.696884+00:00 app[web.1]:
2020-05-20T20:13:05.696884+00:00 app[web.1]:
2020-05-20T20:13:05.696884+00:00 app[web.1]: <--- JS stacktrace --->
2020-05-20T20:13:05.696885+00:00 app[web.1]:
2020-05-20T20:13:05.696885+00:00 app[web.1]: ==== JS stack trace =========================================
2020-05-20T20:13:05.696886+00:00 app[web.1]:
2020-05-20T20:13:05.696886+00:00 app[web.1]: Security context: 0x2ce3f13008d1
2020-05-20T20:13:05.696887+00:00 app[web.1]: 0: builtin exit frame: captureStackTrace(this=0x2ce3f1301749 2020-05-20T20:13:05.696887+00:00 app[web.1]:
2020-05-20T20:13:05.696888+00:00 app[web.1]: 1: handleErrorFromBinding(aka handleErrorFromBinding) [0xc6e0a539a09] [internal/fs/utils.js:229] [bytecode=0x2...
2020-05-20T20:13:05.696888+00:00 app[web.1]:
2020-05-20T20:13:05.696896+00:00 app[web.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2020-05-20T20:13:05.698061+00:00 app[web.1]: 1: 0xa09830 node::Abort() [node]
2020-05-20T20:13:05.698081+00:00 app[web.1]: 2: 0xa09c55 node::OnFatalError(char const, char const) [node]
2020-05-20T20:13:05.701635+00:00 app[web.1]: 3: 0xb7d71e v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [node]
2020-05-20T20:13:05.701637+00:00 app[web.1]: 4: 0xb7da99 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [node]
2020-05-20T20:13:05.701638+00:00 app[web.1]: 5: 0xd2a1f5 [node]
2020-05-20T20:13:05.701638+00:00 app[web.1]: 6: 0xd2a886 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
2020-05-20T20:13:05.701639+00:00 app[web.1]: 7: 0xd37105 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
2020-05-20T20:13:05.702629+00:00 app[web.1]: 8: 0xd37fb5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
2020-05-20T20:13:05.702630+00:00 app[web.1]: 9: 0xd3aa6c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2020-05-20T20:13:05.703089+00:00 app[web.1]: 10: 0xd02a67 v8::internal::Factory::NewFrameArray(int, v8::internal::AllocationType) [node]
2020-05-20T20:13:05.703713+00:00 app[web.1]: 11: 0xcd1608 [node]
2020-05-20T20:13:05.704349+00:00 app[web.1]: 12: 0xcd1ec3 v8::internal::Isolate::CaptureAndSetSimpleStackTrace(v8::internal::Handlev8::internal::JSReceiver, v8::internal::FrameSkipMode, v8::internal::Handlev8::internal::Object) [node]
2020-05-20T20:13:05.704949+00:00 app[web.1]: 13: 0xc1812d v8::internal::Builtin_ErrorCaptureStackTrace(int, unsigned long, v8::internal::Isolate) [node]
2020-05-20T20:13:05.705742+00:00 app[web.1]: 14: 0x13c5c79 [node]
2020-05-20T20:13:05.735032+00:00 app[web.1]: Aborted
2020-05-20T20:13:05.737831+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-20T20:13:05.738116+00:00 app[web.1]: npm ERR! errno 134
2020-05-20T20:13:05.739134+00:00 app[web.1]: npm ERR! [email protected] build: tsc -p tsconfig.build.json
2020-05-20T20:13:05.739225+00:00 app[web.1]: npm ERR! Exit status 134
2020-05-20T20:13:05.739420+00:00 app[web.1]: npm ERR!
2020-05-20T20:13:05.739559+00:00 app[web.1]: npm ERR! Failed at the [email protected] build script.
2020-05-20T20:13:05.739697+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-20T20:13:05.747295+00:00 app[web.1]:
2020-05-20T20:13:05.747513+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-20T20:13:05.747596+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-20T20_13_05_740Z-debug.log
2020-05-20T20:13:05.753640+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-20T20:13:05.753839+00:00 app[web.1]: npm ERR! errno 134
2020-05-20T20:13:05.754794+00:00 app[web.1]: npm ERR! [email protected] prestart:prod: rimraf dist && npm run build
2020-05-20T20:13:05.754875+00:00 app[web.1]: npm ERR! Exit status 134
2020-05-20T20:13:05.754984+00:00 app[web.1]: npm ERR!
2020-05-20T20:13:05.755072+00:00 app[web.1]: npm ERR! Failed at the [email protected] prestart:prod script.
2020-05-20T20:13:05.755153+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-20T20:13:05.761376+00:00 app[web.1]:
2020-05-20T20:13:05.761378+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-20T20:13:05.761379+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-20T20_13_05_755Z-debug.log

Expected behavior

Run it as in my local env and reach the service through /graphql endpoint.

Environment

Nest version: 6.0.0


For Tooling issues:
- Node version: 11.0.0
- Platform:  Mac OS Catalina 10.15.3

Others:

Were you able to solve this issue @sk8Guerra

@ionaryder no. I moved to AWS, and everything worked fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mishelashala picture mishelashala  路  3Comments

cdiaz picture cdiaz  路  3Comments

2233322 picture 2233322  路  3Comments

KamGor picture KamGor  路  3Comments

JulianBiermann picture JulianBiermann  路  3Comments