@pnpm/fs.graceful-fs 1100.2.0 → 1100.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +15 -5
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @pnpm/fs.graceful-fs
|
|
2
2
|
|
|
3
|
+
## 1100.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Windows filesystem operations now retry permission errors for up to one second. Permanent permission errors previously delayed failure by a minute. Sharing and lock violations retain their one-minute retry budget [pnpm/pnpm#14682](https://github.com/pnpm/pnpm/issues/14682).
|
|
8
|
+
|
|
3
9
|
## 1100.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -21,9 +21,10 @@ declare const _default: {
|
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
23
23
|
/**
|
|
24
|
-
* Renames `src` over `dest`,
|
|
25
|
-
* EPERM
|
|
26
|
-
*
|
|
24
|
+
* Renames `src` over `dest`, retrying Windows EBUSY errors for up to a minute.
|
|
25
|
+
* EPERM and EACCES have a one-second budget because they can also indicate
|
|
26
|
+
* permanent permission or destination conflicts. Other errors are thrown
|
|
27
|
+
* right away.
|
|
27
28
|
*
|
|
28
29
|
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
29
30
|
* still be reading that dirent, and a reader has to see either the whole file
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import util, { promisify } from 'node:util';
|
|
3
3
|
import gfs from 'graceful-fs';
|
|
4
4
|
const RENAME_RETRY_BUDGET_MS = 60_000;
|
|
5
|
+
const PERMISSION_DENIED_RETRY_BUDGET_MS = 1_000;
|
|
5
6
|
const RENAME_RETRY_BACKOFF_CAP_MS = 100;
|
|
6
7
|
const renameRetrySleepBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
7
8
|
export default {
|
|
@@ -46,9 +47,10 @@ function withEagainRetry(fn, maxRetries = 15) {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
* Renames `src` over `dest`,
|
|
50
|
-
* EPERM
|
|
51
|
-
*
|
|
50
|
+
* Renames `src` over `dest`, retrying Windows EBUSY errors for up to a minute.
|
|
51
|
+
* EPERM and EACCES have a one-second budget because they can also indicate
|
|
52
|
+
* permanent permission or destination conflicts. Other errors are thrown
|
|
53
|
+
* right away.
|
|
52
54
|
*
|
|
53
55
|
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
54
56
|
* still be reading that dirent, and a reader has to see either the whole file
|
|
@@ -57,16 +59,24 @@ function withEagainRetry(fn, maxRetries = 15) {
|
|
|
57
59
|
export function renameFileWithRetry(src, dest) {
|
|
58
60
|
const startedAt = Date.now();
|
|
59
61
|
let backoffMs = 0;
|
|
62
|
+
let budgetMs = RENAME_RETRY_BUDGET_MS;
|
|
60
63
|
for (;;) {
|
|
61
64
|
try {
|
|
62
65
|
fs.renameSync(src, dest);
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
68
|
catch (err) {
|
|
66
|
-
if (!isTransientRenameError(err)
|
|
69
|
+
if (!isTransientRenameError(err))
|
|
70
|
+
throw err;
|
|
71
|
+
if (err.code === 'EPERM' || err.code === 'EACCES')
|
|
72
|
+
budgetMs = Math.min(budgetMs, PERMISSION_DENIED_RETRY_BUDGET_MS);
|
|
73
|
+
const remainingMs = budgetMs - (Date.now() - startedAt);
|
|
74
|
+
if (remainingMs <= 0)
|
|
67
75
|
throw err;
|
|
68
76
|
if (backoffMs > 0)
|
|
69
|
-
Atomics.wait(renameRetrySleepBuffer, 0, 0, backoffMs);
|
|
77
|
+
Atomics.wait(renameRetrySleepBuffer, 0, 0, Math.min(backoffMs, remainingMs));
|
|
78
|
+
if (Date.now() - startedAt >= budgetMs)
|
|
79
|
+
throw err;
|
|
70
80
|
backoffMs = Math.min(backoffMs + 10, RENAME_RETRY_BACKOFF_CAP_MS);
|
|
71
81
|
}
|
|
72
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fs.graceful-fs",
|
|
3
|
-
"version": "1100.2.
|
|
3
|
+
"version": "1100.2.1",
|
|
4
4
|
"description": "Promisified graceful-fs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"graceful-fs": "^4.2.11"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@
|
|
33
|
+
"@jest/globals": "30.4.1",
|
|
34
|
+
"@pnpm/fs.graceful-fs": "1100.2.1",
|
|
34
35
|
"@types/graceful-fs": "^4.1.9"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
@@ -40,8 +41,9 @@
|
|
|
40
41
|
"preset": "@pnpm/jest-config"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
|
-
"lint": "eslint \"src/**/*.ts\"",
|
|
44
|
-
"test": "pn compile",
|
|
45
|
-
"compile": "tsgo --build && pn lint --fix"
|
|
44
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
45
|
+
"test": "pn compile && pn .test",
|
|
46
|
+
"compile": "tsgo --build && pn lint --fix",
|
|
47
|
+
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
|
46
48
|
}
|
|
47
49
|
}
|