Skip to content

failed to compile wasm module: RangeError: WebAssembly.Instance(): Out of memory: wasm memory #4916

@maggie44

Description

@maggie44

Self-service

  • I'd be willing to implement a fix

Describe the bug

I am seeing failures when running yarn install on 3.2.2 (it continues on for many more packages, but chosen the below just as examples:

failed to compile wasm module: RangeError: WebAssembly.Instance(): Out of memory: wasm memory

[balena-example]  failed to compile wasm module: RangeError: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]  
[balena-example]  ➤ YN0001: │ RangeError: @cspotcode/source-map-support@npm:0.8.1: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]      at Sh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:231902)
[balena-example]      at vh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:232663)
[balena-example]      at /build-context/.yarn/releases/yarn-3.2.2.cjs:198:48232
[balena-example]      at D5 (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17260)
[balena-example]      at fn (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17295)
[balena-example]      at Object.iNe (/build-context/.yarn/releases/yarn-3.2.2.cjs:423:4258)
[balena-example]      at async Qo.fetchFromNetwork (/build-context/.yarn/releases/yarn-3.2.2.cjs:710:25275)
[balena-example]      at async p (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1414)
[balena-example]      at async m (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1769)
[balena-example]      at async y (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:2778)
[balena-example]  ➤ YN0013: │ aproba@npm:2.0.0 can't be found in the cache and will be fetched from the remote registry
[balena-example]  failed to compile wasm module: RangeError: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]  
[balena-example]  ➤ YN0001: │ RangeError: @humanwhocodes/module-importer@npm:1.0.1: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]      at Sh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:231902)
[balena-example]      at vh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:232663)
[balena-example]      at /build-context/.yarn/releases/yarn-3.2.2.cjs:198:48232
[balena-example]      at D5 (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17260)
[balena-example]      at fn (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17295)
[balena-example]      at Object.iNe (/build-context/.yarn/releases/yarn-3.2.2.cjs:423:4258)
[balena-example]      at async Qo.fetchFromNetwork (/build-context/.yarn/releases/yarn-3.2.2.cjs:710:25275)
[balena-example]      at async p (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1414)
[balena-example]      at async m (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1769)
[balena-example]      at async y (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:2778)
[balena-example]  ➤ YN0013: │ are-we-there-yet@npm:3.0.1 can't be found in the cache and will be fetched from the remote registry
[balena-example]  failed to compile wasm module: RangeError: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]  
[balena-example]  ➤ YN0001: │ RangeError: @tsconfig/node10@npm:1.0.9: WebAssembly.Instance(): Out of memory: wasm memory
[balena-example]      at Sh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:231902)
[balena-example]      at vh (/build-context/.yarn/releases/yarn-3.2.2.cjs:196:232663)
[balena-example]      at /build-context/.yarn/releases/yarn-3.2.2.cjs:198:48232
[balena-example]      at D5 (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17260)
[balena-example]      at fn (/build-context/.yarn/releases/yarn-3.2.2.cjs:392:17295)
[balena-example]      at Object.iNe (/build-context/.yarn/releases/yarn-3.2.2.cjs:423:4258)
[balena-example]      at async Qo.fetchFromNetwork (/build-context/.yarn/releases/yarn-3.2.2.cjs:710:25275)
[balena-example]      at async p (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1414)
[balena-example]      at async m (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:1769)
[balena-example]      at async y (/build-context/.yarn/releases/yarn-3.2.2.cjs:429:2778)
[balena-example]  ➤ YN0013: │ arg@npm:4.1.3 can't be found in the cache and will be fetched from the remote registry

...

It occurs only when doing builds on a balena Cloud builder which uses Docker to build images, and only when using ARMv8 Docker images (all x64 and arm64 work fine) (node:18.9.1-alpine3.16, but tried others back to 14). There is plenty of memory available (even more available on the ARMv8 builders than the x64 and arm64). When I do the same yarn install on a ARMv8 device directly it works ok, it seems to be only related to Docker buildx builds.

This is a really difficult one to provide a means for people to reproduce and debug, so logging instead here an issue to see if anyone might have any ideas on what to explore, or thoughts that come to mind on why this is failing. Here is the repo using to test which generates the issue: https://github.com/maggie0002/yarn-test

I have been reading a lot about the ZipFS and memory allocation, I am wondering if that could be related? This issue doesn't occur on Yarn 2 or Yarn classic, but does occur on all Yarn 3 including latest.

To reproduce

Not really reproducible without registering with balena and using the cloud builders. Here is the repo being pushed though: https://github.com/maggie0002/yarn-test

Environment

System:
OS: Linux 5.4 Alpine Linux
CPU: (64) arm ARMv8 Processor rev 2 (v8l)
Binaries:
Node: 18.9.1 - /tmp/xfs-7a53860c/node
Yarn: 2.4.3 - /tmp/xfs-7a53860c/yarn
npm: 8.19.1 - /usr/local/bin/npm

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupholdedReal issues without formal reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions