-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which packages are impacted by your issue?
@graphql-codegen/cli
Describe the bug
When running graphql-codegen in the CLI, the return value of os.cpus().length is passed into task.newListr. However, in some Sandbox environments, os.cpus() returns an empty array, resulting in passing the value 0 into the concurrent property of newListr. This in turn results in the generation hanging.
The Node JS documentation mentions:
os.cpus().length should not be used to calculate the amount of parallelism available to an application. Use os.availableParallelism() for this purpose.
Your Example Website or App
https://stackblitz.com/edit/github-ntbvauxb?file=package.json
Steps to Reproduce the Bug or Issue
- In the StackBlitz example, I've added a shim to mimic the sandbox response for
os.cpus() - Run
yarn generateto see the error - Change the assignment in
force-no-cpus.jstoos.cpus = () => ["x"];and re-runyarn generateand you'll see that generation now works, given that["x"].lengthis equal to1
Expected behavior
I expect that the concurrency value is set to a minimum of 1, and/or uses the newer availableParallelism() function.
Screenshots or Videos
No response
Platform
- OS: macOS in Codex CLI
- NodeJS: v20.19.2
graphqlversion: 16.9.0@graphql-codegen/cliversion: 5.0.7
Codegen Config File
No response
Additional context
I'm happy to submit a PR to address this, if it's agreeable to do so.