同じリポジトリやforkしたリポジトリを別にcloneして動かそうとしたら、下記エラーで動かず。
元々のリポジトリは問題なし。
FATAL ERROR: wasm code commit Allocation failed - process out of memory

yarn.lockをGit管理していたのが原因でした。
rails webpacker:installではなく、yarnコマンドを実行すれば良かった。

コンソール

[Webpacker] Compiling...
[Webpacker] Compilation failed:
warning package.json: No license field

<--- Last few GCs --->

[76554:0x160008000]      108 ms: Scavenge 10.2 (15.8) -> 7.3 (15.8) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[76554:0x160008000]      124 ms: Scavenge 11.4 (16.3) -> 9.0 (17.3) MB, 0.5 / 0.1 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[76554:0x160008000]      145 ms: Scavenge 13.7 (18.6) -> 11.1 (19.8) MB, 0.5 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x1021e29d8 node::Abort() [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 2: 0x10227ab58 node::errors::TryCatchScope::~TryCatchScope() [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 3: 0x102394384 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 4: 0x102394318 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 5: 0x102929cdc v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 6: 0x10292a970 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(int, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 7: 0x102929638 v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 8: 0x10292a780 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
 9: 0x10292ccf4 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
10: 0x102938808 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
11: 0x102905130 v8::internal::wasm::CompileToNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, v8::internal::wasm::ModuleWireBytes const&, v8::internal::Handle<v8::internal::FixedArray>*) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
12: 0x10293565c v8::internal::wasm::WasmEngine::SyncCompile(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, v8::internal::wasm::ModuleWireBytes const&) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
13: 0x10295c364 v8::(anonymous namespace)::WebAssemblyModule(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
14: 0x1023fd094 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
15: 0x1023fc3f8 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
16: 0x1023fbef4 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
17: 0x102b11fec Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
18: 0x102aa679c Builtins_JSBuiltinsConstructStub [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
19: 0x102b8ef2c Builtins_ConstructHandler [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
20: 0x102aaac54 Builtins_InterpreterEntryTrampoline [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
21: 0x102aa3a24 Builtins_ArgumentsAdaptorTrampoline [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
22: 0x102aaac54 Builtins_InterpreterEntryTrampoline [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]

 <省略>

131: 0x102aaac54 Builtins_InterpreterEntryTrampoline [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
132: 0x102aa8504 Builtins_JSEntryTrampoline [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
133: 0x102aa81a8 Builtins_JSEntry [/Users/xxxx/.nvm/versions/node/v14.15.4/bin/node]
134: 0x160008000 

Completed 500 Internal Server Error in 1067ms (ActiveRecord: 1.2ms | Allocations: 434614)


ActionView::Template::Error (Webpacker can't find application in /Users/xxxx/workspace/rails-app-origin/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
     6:     <%= csrf_meta_tags %>
     7:     <%= csp_meta_tag %>
     8:     <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     9:     <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
    10:   </head>
    11:   <body>
    12:     <h1><%= link_to t('app_name'), "#{domain}#{root_path}" %></h1>
  
app/views/layouts/application.html.erb:8

解消手順

【訂正】rails webpacker:installではなく、yarnコマンドを実行すれば良かった。
yarnでwebpackerやnode_modulesも管理しているという事らしい。

$ rm -f yarn.lock	# <- これが原因
$ rm -f package.json	# <- 序でに削除
$ rm -f package-lock.json	# <- 序でに削除
$ vi .gitignore
/yarn.lock
/package.json
/package-lock.json
$ rails webpacker:install
? n
$ yarn
yarn install v1.22.10
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning @rails/webpacker > node-sass > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > request > har-validator@5.1.5: this library is no longer supported
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning webpack-dev-server > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 11.39s.

$ rails s

今回のコミット内容
https://dev.azure.com/nightonly/rails-app-origin/_git/rails-app-origin/commit/2b3a832fe9a2d0074c5ab1df249545f9ce4530a9

修正したコミット内容
https://dev.azure.com/nightonly/rails-app-origin/_git/rails-app-origin/commit/ac25fa6f43261fe25a715c9b92853bc8ead3802e

序でに

<%= button_to '画像削除', users_image_path, data: { confirm: '本当に削除しますか?' }, method: :delete %>

上記の影響で、JSで出している確認のポップアップが出なくなった。
@rails/ujsで実現していて、yarnでインストールしていたから。

ブラウザのConsoleでエラーが出ていました。
application.js:6 Uncaught Error: Cannot find module '@rails/ujs'

$ yarn add @rails/ujs

application.js:7 Uncaught Error: Cannot find module 'turbolinks'

$ yarn add turbolinks

application.js:8 Uncaught Error: Cannot find module '@rails/activestorage'

$ yarn add @rails/activestorage

エラーは出なくなったが、念の為、下記も実行

$ yarn add channels

これらも含めpackage.jsonで管理していて、
「yarn」と打つだけでインストールされたという事でした。

ボツ案

下記でも解消したが、待ち時間が長いのと、そもそもの原因への直接的な対策ではなさそう。

https://stackoverflow.com/questions/13616770/node-js-fatal-error-js-allocation-failed-process-out-of-memory-possible

$ node --max-old-space-size=250 `which npm` i

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です