Unable to deploy my NodeJS app (Javascript heap out of memory)

Unable to deploy my nodejs app, works perfectly on my development server but when I try to deploy it, i keep running into errors. Even tried to scale my memory but still doesn’t work.

Here are the logs attached.

2023-05-27T15:16:14.877 app[8f4248e6] sin [info] npm notice

2023-05-27T15:16:14.877 app[8f4248e6] sin [info] npm notice New major version of npm available! 8.15.0 → 9.6.7

2023-05-27T15:16:14.877 app[8f4248e6] sin [info] npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.7

2023-05-27T15:16:14.877 app[8f4248e6] sin [info] npm notice Run npm install -g npm@9.6.7 to update!

2023-05-27T15:16:14.877 app[8f4248e6] sin [info] npm notice

2023-05-27T15:16:15.877 app[8f4248e6] sin [info] haarting clean up.

2023-05-27T15:16:15.878 app[8f4248e6] sin [info] hallpass exited, pid: 522, status: signal: 15

2023-05-27T15:16:15.882 app[8f4248e6] sin [info] 2023/05/27 15:16:15 listening on [fdaa:0:bed9:a7b:12a:8f42:48e6:2]:22 (DNS: [fdaa::3]:53)

2023-05-27T15:16:20.862 runner[8f4248e6] sin [info] Starting instance

2023-05-27T15:16:20.917 runner[8f4248e6] sin [info] Configuring virtual machine

2023-05-27T15:16:20.918 runner[8f4248e6] sin [info] Pulling container image

2023-05-27T15:16:22.015 runner[8f4248e6] sin [info] Unpacking image

2023-05-27T15:16:22.018 runner[8f4248e6] sin [info] Preparing kernel init

2023-05-27T15:16:22.240 runner[8f4248e6] sin [info] Configuring firecracker

2023-05-27T15:16:22.479 runner[8f4248e6] sin [info] Starting virtual machine

2023-05-27T15:16:22.685 app[8f4248e6] sin [info] Starting init (commit: 8af0ddf)…

2023-05-27T15:16:22.712 app[8f4248e6] sin [info] Preparing to run: npm run start as root

2023-05-27T15:16:22.732 app[8f4248e6] sin [info] 2023/05/27 15:16:22 listening on [fdaa:0:bed9:a7b:12a:8f42:48e6:2]:22 (DNS: [fdaa::3]:53)

2023-05-27T15:16:23.450 app[8f4248e6] sin [info] > learning-management-system@0.0.1 start

2023-05-27T15:16:23.450 app[8f4248e6] sin [info] > ts-node index.ts

2023-05-27T15:16:30.975 health[8f4248e6] sin [error] Health check on port 3001 has failed. Your app is not responding properly. Services exposed on ports [80, 443] will have intermittent failures until the health check passes.

2023-05-27T15:16:38.231 app[8f4248e6] sin [info] <— Last few GCs —>

2023-05-27T15:16:38.231 app[8f4248e6] sin [info] [539:0x6488140] 14294 ms: Mark-sweep (reduce) 487.7 (499.2) → 487.2 (497.4) MB, 334.6 / 0.0 ms (+ 89.4 ms in 25 steps since start of marking, biggest step 21.2 ms, walltime since start of marking 478 ms) (average mu = 0.260, current mu = 0.230) alloc[539:0x6488140] 14756 ms: Mark-sweep (reduce) 488.4 (497.6) → 487.2 (497.6) MB, 345.2 / 0.0 ms (+ 90.7 ms in 15 steps since start of marking, biggest step 17.6 ms, walltime since start of marking 461 ms) (average mu = 0.164, current mu = 0.055) alloc

2023-05-27T15:16:38.231 app[8f4248e6] sin [info] <— JS stacktrace —>

2023-05-27T15:16:38.231 app[8f4248e6] sin [info] FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

2023-05-27T15:16:38.237 app[8f4248e6] sin [info] 1: 0xb02930 node::Abort() [node]

2023-05-27T15:16:38.238 app[8f4248e6] sin [info] 2: 0xa18149 node::FatalError(char const*, char const*) [node]

2023-05-27T15:16:38.246 app[8f4248e6] sin [info] 3: 0xcdd16e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]

2023-05-27T15:16:38.247 app[8f4248e6] sin [info] 4: 0xcdd4e7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]

2023-05-27T15:16:38.247 app[8f4248e6] sin [info] 5: 0xe94b55 [node]

2023-05-27T15:16:38.251 app[8f4248e6] sin [info] 6: 0xea481d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]

2023-05-27T15:16:38.251 app[8f4248e6] sin [info] 7: 0xea751e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]

2023-05-27T15:16:38.252 app[8f4248e6] sin [info] 8: 0xe68a5a v8::internal::factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]

2023-05-27T15:16:38.252 app[8f4248e6] sin [info] 9: 0x11e17c6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]

2023-05-27T15:16:38.263 app[8f4248e6] sin [info] 10: 0x15d5439 [node]

2023-05-27T15:16:38.292 app[8f4248e6] sin [info] Aborted

Thank you very much for the help!

Try scaling the app memory:
fly scale memory 2048

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.