GAミント至上主義

Web Monomaniacal Developer.

Nuxt v3.0.0でnuxt generate時のメモリエラー FATAL ERROR: Reached heap limit Allocation failed

Nuxt v3.0.0のテスト用プロジェクトで、GitHub Actionsでデプロイさせるためにnuxt generateコマンドを実行したところメモリ不足のエラーが出た。

ローカル環境では問題なく成功するし、GitHub Actionsでも成功するときもあるのでメモリリーク的な印象。

メモリを食うようなコード量もライブラリもなく、CIでもメモリ2GBはありそうなので、スペック的には問題ないはず。

<--- Last few GCs --->

[1844:0x624fd70]    77610 ms: Scavenge 2024.9 (2068.5) -> 2024.2 (2078.5) MB, 15.6 / 0.0 ms  (average mu = 0.502, current mu = 0.257) allocation failure 
[1844:0x624fd70]    77662 ms: Scavenge 2030.8 (2078.5) -> 2028.6 (2079.5) MB, 11.1 / 0.0 ms  (average mu = 0.502, current mu = 0.257) allocation failure 
[1844:0x624fd70]    78162 ms: Scavenge 2031.8 (2079.5) -> 2030.2 (2099.5) MB, 475.8 / 0.0 ms  (average mu = 0.502, current mu = 0.257) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb06730 node::Abort() [node]
 2: 0xa1b6d0  [node]
 3: 0xce1e60 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xce2207 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xe99875  [node]
 6: 0xea953d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xeac23e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xe6d77a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
 9: 0x11e64e6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x15da159  [node]
 ELIFECYCLE  Command failed with exit code 134.
Aborted (core dumped)
Error: Process completed with exit code 1.

issueを探すとそれっぽいのを発見。

github.com

コメントにあったこちらの設定を追加したところエラーが出ることがなくなった。

export default defineNuxtConfig({
  sourcemap: false
})

Vite側の問題っぽいのでバージョンアップが含まれるv3.1.0で直るかもしれないけど詳しくは見てない

github.com