`FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory`がGitHub Actionsで発生した場合の対処法
問題
次のようなエラーが発生してしまい、GitHub Actions上で実行していたテストがFAILED
してしまった。
<--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0xb02930 node::Abort() [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 2: 0xa18149 node::FatalError(char const*, char const*) [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 3: 0xcdd16e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 4: 0xcdd4e7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 5: 0xe94b55 [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 6: 0xe95636 [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 7: 0xea3b5e [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 8: 0xea45a0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/16.17.0/x64/bin/node] 9: 0xea751e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) ....
結論
NODE_OPTIONS: "--max-old-space-size=5120""
をenvに追加する
... - name: Run all the tests run: yarn test working-directory: ./path/into/app env: ... NODE_OPTIONS: "--max-old-space-size=5120" ...