Using Yarn 2 causes ENOMEM

Hello, Fly community!

I’ve upgraded one of my projects to use Yarn 2, which involves using “yarn node .” instead of “node .” to configure Node for PnP, and I believe some other things.

When deploying this to Fly and trying to run it, I see the following error:

2021-03-25T17:23:27Z [info] Internal Error: spawn ENOMEM
2021-03-25T17:23:27Z [info]     at Object.spawn (child_process.js:553:9)
2021-03-25T17:23:27Z [info]     at ChildProcess.spawn (internal/child_process.js:403:11)
2021-03-25T17:23:27Z [info]     at Module.g (/app/.yarn/releases/yarn-2.4.1.cjs:2:404527)
2021-03-25T17:23:27Z [info]     at i (/app/.yarn/releases/yarn-2.4.1.cjs:17:21887)
2021-03-25T17:23:27Z [info]     at async a.mktempPromise (/app/.yarn/releases/yarn-2.4.1.cjs:2:514978)
2021-03-25T17:23:27Z [info]     at /app/.yarn/releases/yarn-2.4.1.cjs:2:58971
2021-03-25T17:23:27Z [info]     at async ae.execute (/app/.yarn/releases/yarn-2.4.1.cjs:2:58912)
2021-03-25T17:23:27Z [info]     at async Y.run (/app/.yarn/releases/yarn-2.4.1.cjs:17:3854)
2021-03-25T17:23:27Z [info]     at async ae.validateAndExecute (/app/.yarn/releases/yarn-2.4.1.cjs:2:660570)
2021-03-25T17:23:27Z [info]     at async fe.validateAndExecute (/app/.yarn/releases/yarn-2.4.1.cjs:2:660570)

This error means that Node is running into memory limits, though when running “node .” instead of “yarn node .”, it works fine but I cannot do that because I’m using PnP with Yarn.

I was wondering whether anyone uses runs Yarn 2 on Fly without this issue?

I haven’t used yarn 2 personally but there’s no reason it shouldn’t work. Are you seeing that error when building your app or after deploying?

I see this when after deploying. Fly’s health checks identify the crash and just rolls back which is cool.

You can check the memory usage in the dashboard and increase it if necessary like this:

flyctl scale memory 2048 -a app-name

Edit: you also might want to limit how much memory node can use by setting --max-old-space-size to maybe ~75% of the total vm memory. Here’s some docs Command-line options | Node.js v15.12.0 Documentation.

1 Like

Hey. Were you able to resolve the issue? I seem to have encountered the same problem with Yarn 3.

After transitioning from npm to Yarn (with PnP), the app wasn’t able to start. I played a little bit with max-old-space-size node option, which seem to have improved the situation a little.

Yet the app still throws ENONEM on the first startup. After 1-2 restarts, it seems to be running OK, however.

Just jumping in here as I’ve just hit the same issue with Yarn V3.

I will debug solutions, but for me it’s on the release command.

So it seems something about V3 just CHUNKS memory??

Scaling did seem to resolve it, but I was surprised to see it ENOMEM just from startup :eyes: