Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ graph LR;
npmcli-arborist-->bin-links;
npmcli-arborist-->cacache;
npmcli-arborist-->common-ancestor-path;
npmcli-arborist-->gar-promise-retry["@gar/promise-retry"];
npmcli-arborist-->hosted-git-info;
npmcli-arborist-->isaacs-string-locale-compare["@isaacs/string-locale-compare"];
npmcli-arborist-->json-stringify-nice;
Expand Down
1 change: 1 addition & 0 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14440,6 +14440,7 @@
"version": "9.4.0",
"license": "ISC",
"dependencies": {
"@gar/promise-retry": "^1.0.0",
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/fs": "^5.0.0",
"@npmcli/installed-package-contents": "^4.0.0",
Expand Down
12 changes: 10 additions & 2 deletions workspaces/arborist/lib/arborist/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const runScript = require('@npmcli/run-script')
const { callLimit: promiseCallLimit } = require('promise-call-limit')
const { depth: dfwalk } = require('treeverse')
const { isNodeGypPackage, defaultGypInstallScript } = require('@npmcli/node-gyp')
const { promiseRetry } = require('@gar/promise-retry')
const { log, time } = require('proc-log')
const { resolve } = require('node:path')

Expand Down Expand Up @@ -381,13 +382,20 @@ module.exports = cls => class Builder extends cls {

const timeEnd = time.start(`build:link:${node.location}`)

const p = binLinks({
// On Windows, antivirus/indexer can transiently lock files, causing EPERM/EACCES/EBUSY on the rename inside write-file-atomic (used by bin-links/fix-bin.js), so, retry with backoff.
const p = promiseRetry((retry) => binLinks({
pkg: node.package,
path: node.path,
top: !!(node.isTop || node.globalTop),
force: this.options.force,
global: !!node.globalTop,
})
}).catch(/* istanbul ignore next - Windows-only transient antivirus locks */ err => {
if (process.platform === 'win32' &&
(err.code === 'EPERM' || err.code === 'EACCES' || err.code === 'EBUSY')) {
return retry(err)
}
throw err
}), { retries: 5, minTimeout: 500 })

await (this.#doHandleOptionalFailure
? this[_handleOptionalFailure](node, p)
Expand Down
1 change: 1 addition & 0 deletions workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "9.4.0",
"description": "Manage node_modules trees",
"dependencies": {
"@gar/promise-retry": "^1.0.0",
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/fs": "^5.0.0",
"@npmcli/installed-package-contents": "^4.0.0",
Expand Down
Loading