Skip to content

fix(core): handle case when os.cpus().length is 0#3090

Merged
arcanis merged 1 commit intomasterfrom
paul/fix/cpus
Jul 6, 2021
Merged

fix(core): handle case when os.cpus().length is 0#3090
arcanis merged 1 commit intomasterfrom
paul/fix/cpus

Conversation

@paul-soporan
Copy link
Copy Markdown
Member

What's the problem this PR addresses?

When libuv's code that retrieves the cpus fails, Node falls back to [] as the return value for os.cpus().

This causes Yarn to try to create a pool with 0 concurrent workers (which causes p-queue to throw) on unsupported platforms such as Android.

How did you fix it?

Use Math.max(1, cpus.length()).

The yarn workspaces foreach command doesn't suffer from this issue because it already uses 1 as a fallback.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@paul-soporan paul-soporan requested a review from arcanis as a code owner July 5, 2021 20:55
@arcanis arcanis merged commit dcd2886 into master Jul 6, 2021
@arcanis arcanis deleted the paul/fix/cpus branch July 6, 2021 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants