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 (/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.