berry: [Bug?]: Couldn't allocate enough memory on Windows x86

Self-service

  • I’d be willing to implement a fix

Describe the bug

Couldn’t allocate enough memory during installation

To reproduce

https://github.com/Brooooooklyn/Image/runs/4786431120?check_suite_focus=true

Environment

Os: Windows 32 bit
Node: 16.13.2

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I’m able to reproduce this every time by using docker buildx build --platform linux/arm64 or linux/arm/v7. Something’s up with the ZipFS (maybe wasm on ARM?).

As a workaround, I tried reducing the maxOpenFiles for every ZipOpenFs instance, which worked. The build didn’t run out of memory, but oh boy was it slow. Only modifying the node-modules linker’s maxOpenFiles also worked.

So to make it work, I just searched and replaced every maxOpenFiles:80 in .yarn/releases/yarn-3.6.0.cjs to maxOpenFiles:4 or maxOpenFiles:10 or something low until it worked.

i’m getting the same error Couldn't allocate enough memory in a fresh Ubuntu 23.04 Docker container using aarch64 and Node.js 20.6.1 and Yarn 3.6.3.

i’m using a Macbook Pro Max M2 and already configured Docker for Mac Settings to use up to 40 out of my 64Gb of memory

i tried your solution by running

sed -i 's/maxOpenFiles:80/maxOpenFiles:10/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following

time yarn install --network-timeout 1000000000

then i still get error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 16s 266ms
➤ YN0000: Failed with errors in 45s 772ms

real	0m46.520s
user	0m22.146s
sys	0m7.962s

so i changed maxOpenFiles from 10 to 4 by running

sed -i 's/maxOpenFiles:10/maxOpenFiles:4/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following again

time yarn install --network-timeout 1000000000

and got same error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 15s 289ms
➤ YN0000: Failed with errors in 42s 942ms

real	0m43.719s
user	0m21.505s
sys	0m7.707s

so lastly i changed maxOpenFiles from 4 to 1 by running the following and checking the file had changed

sed -i 's/maxOpenFiles:4/maxOpenFiles:1/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following again

time yarn install --network-timeout 1000000000

and got same error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 14s 861ms
➤ YN0000: Failed with errors in 42s 292ms

real	0m43.046s
user	0m21.005s
sys	0m6.910s

It happens not only in windows and macos, but on linux too https://github.com/yarnpkg/berry/issues/3580