FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 921 forks source link

🐛 BUG: Installing @snowpack/plugin-webpack runs out of memory. #3648

Open HamishWHC opened 3 years ago

HamishWHC commented 3 years ago

Quick checklist

What package manager are you using?

npm (7.20.5)

What operating system are you using?

Linux (Pop OS 21.04)

Describe the bug

I was installing the webpack plugin so I could minify my builds, but after a few seconds npm gets stuck on a line. 15 minutes later it crashes due to it using too much memory (in system monitor I saw it using about 4.5GB of memory before it crashed).

Log:

❯ npm install --save-dev @snowpack/plugin-webpack
⸨########⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠧ idealTree:webpack: timing idealTree:node_modules/webpack Completed in 135ms
<--- Last few GCs --->

[8304:0x59a7ae0]   803824 ms: Scavenge (reduce) 4076.2 (4100.6) -> 4075.3 (4101.8) MB, 5.3 / 0.0 ms  (average mu = 0.236, current mu = 0.213) allocation failure 
[8304:0x59a7ae0]   805372 ms: Mark-sweep (reduce) 4076.3 (4103.8) -> 4073.9 (4103.8) MB, 1537.2 / 0.1 ms  (average mu = 0.232, current mu = 0.228) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa24ed0 node::Abort() [npm install @snowpack/plugin-webpack]
 2: 0x966115 node::FatalError(char const*, char const*) [npm install @snowpack/plugin-webpack]
 3: 0xb9acde v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [npm install @snowpack/plugin-webpack]
 4: 0xb9b057 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [npm install @snowpack/plugin-webpack]
 5: 0xd56ea5  [npm install @snowpack/plugin-webpack]
 6: 0xd57a2f  [npm install @snowpack/plugin-webpack]
 7: 0xd65abb v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [npm install @snowpack/plugin-webpack]
 8: 0xd6967c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm install @snowpack/plugin-webpack]
 9: 0xd37d2b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [npm install @snowpack/plugin-webpack]
10: 0x108035f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [npm install @snowpack/plugin-webpack]
11: 0x1427079  [npm install @snowpack/plugin-webpack]
Aborted (core dumped)

Steps to reproduce

  1. npx create-snowpack-app crash-test --template=@snowpack/app-template-react-typescript
  2. npm i -D @snowpack/plugin-webpack
  3. Await crash in about 15 minutes time.

Link to minimal reproducible example (optional)

No response

gbenson-ff commented 3 years ago

I'm affected by this bug as well, on Arch Linux with npm 7.20.5.

I can reproduce by entering an empty directory, running npm init -y immediately followed by npm i -D @snowpack/plugin-webpack

Edit: Bug is also present for me on Windows 10 with npm 7.20.3.

Installing @snowpack/plugin-webpack@2.3.1 does not cause any issue. 3.0.0 and 3.0.0-pre.0 both cause a memory leak.

wiflmail commented 3 years ago

There is an upstream dependency conflict, since npm v7 now installs peerDependencies by default: @snowpack/plugin-webpack@3.0.0 needs webpack@"^5.34.0" but also peer webpack@"^4.44.2" from webpack-manifest-plugin@"^3.1.1"

If you can't wait for solution, bypass the peerDependency auto-installation with npm i -D @snowpack/plugin-webpack --legacy-peer-deps

TicTak21 commented 2 years ago

+1

npm: v7.21.0 MacOS Catalina