Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This prevents an empty event loop on systems that have no results for os.cpus()
  • Loading branch information
wraithgar committed Apr 3, 2023
1 parent 54795a3 commit deca335
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
11 changes: 10 additions & 1 deletion node_modules/promise-call-limit/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
const defLimit = require('os').cpus().length
const os = require('os')
// availableParallelism available only since node v19, for older versions use
// cpus() cpus() can return an empty list if /proc is not mounted, use 1 in
// this case

/* istanbul ignore next - version-specific workaround */
const defLimit = 'availableParallelism' in os
? os.availableParallelism()
: Math.max(1, os.cpus().length)

const callLimit = (queue, limit = defLimit) => new Promise((res, rej) => {
let active = 0
let current = 0
Expand Down
4 changes: 2 additions & 2 deletions node_modules/promise-call-limit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-call-limit",
"version": "1.0.1",
"version": "1.0.2",
"files": [
"index.js"
],
Expand All @@ -21,7 +21,7 @@
"check-coverage": true
},
"devDependencies": {
"tap": "^14.10.6"
"tap": "^16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10205,9 +10205,9 @@
}
},
"node_modules/promise-call-limit": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-1.0.1.tgz",
"integrity": "sha512-3+hgaa19jzCGLuSCbieeRsu5C2joKfYn8pY6JAuXFRVfF4IO+L7UPpFWNTeWT9pM7uhskvbPPd/oEOktCn317Q==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-1.0.2.tgz",
"integrity": "sha512-1vTUnfI2hzui8AEIixbdAJlFY4LFDXqQswy/2eOlThAscXCY4It8FdVuI0fMJGAB2aWGbdQf/gv0skKYXmdrHA==",
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
Expand Down Expand Up @@ -15026,7 +15026,7 @@
"parse-conflict-json": "^3.0.0",
"proc-log": "^3.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.1",
"promise-call-limit": "^1.0.2",
"read-package-json-fast": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"parse-conflict-json": "^3.0.0",
"proc-log": "^3.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.1",
"promise-call-limit": "^1.0.2",
"read-package-json-fast": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^10.0.1",
Expand Down

0 comments on commit deca335

Please sign in to comment.