@pnpm/fs.graceful-fs 1100.1.1 → 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 +12 -0
- package/lib/index.d.ts +30 -19
- package/lib/index.js +46 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 1100.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Copying a built package to its other hoisted locations no longer replaces the destination directory. With `nodeLinker: hoisted`, that replacement deleted the dependencies nested inside the destination's `node_modules`, and made concurrent copies of the same build chunk fail with `ERR_PNPM_ENOENT: no such file or directory, rename '.../node_modules/_tmp_...'` [#12880](https://github.com/pnpm/pnpm/issues/12880).
|
|
14
|
+
|
|
3
15
|
## 1100.1.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
chmod: typeof
|
|
4
|
-
copyFile: typeof
|
|
5
|
-
copyFileSync: (src:
|
|
6
|
-
createReadStream: typeof
|
|
7
|
-
link: typeof
|
|
8
|
-
linkSync: (existingPath:
|
|
9
|
-
mkdir: typeof
|
|
10
|
-
mkdirSync: (path:
|
|
11
|
-
renameSync: (oldPath:
|
|
12
|
-
readFile: typeof
|
|
13
|
-
readFileSync: typeof
|
|
14
|
-
readdirSync: typeof
|
|
15
|
-
stat: typeof
|
|
16
|
-
statSync:
|
|
17
|
-
unlink: typeof
|
|
18
|
-
unlinkSync: typeof
|
|
19
|
-
writeFile: typeof
|
|
20
|
-
writeFileSync: (file:
|
|
3
|
+
chmod: typeof fs.chmod.__promisify__;
|
|
4
|
+
copyFile: typeof fs.copyFile.__promisify__;
|
|
5
|
+
copyFileSync: (src: fs.PathLike, dest: fs.PathLike, mode?: number | undefined) => void;
|
|
6
|
+
createReadStream: typeof fs.createReadStream;
|
|
7
|
+
link: typeof fs.link.__promisify__;
|
|
8
|
+
linkSync: (existingPath: fs.PathLike, newPath: fs.PathLike) => void;
|
|
9
|
+
mkdir: typeof fs.mkdir.__promisify__;
|
|
10
|
+
mkdirSync: (path: fs.PathLike, options?: fs.MakeDirectoryOptions | fs.Mode | null | undefined) => string | undefined;
|
|
11
|
+
renameSync: (oldPath: fs.PathLike, newPath: fs.PathLike) => void;
|
|
12
|
+
readFile: typeof fs.readFile.__promisify__;
|
|
13
|
+
readFileSync: typeof fs.readFileSync;
|
|
14
|
+
readdirSync: typeof fs.readdirSync;
|
|
15
|
+
stat: typeof fs.stat.__promisify__;
|
|
16
|
+
statSync: fs.StatSyncFn;
|
|
17
|
+
unlink: typeof fs.unlink.__promisify__;
|
|
18
|
+
unlinkSync: typeof fs.unlinkSync;
|
|
19
|
+
writeFile: typeof fs.writeFile.__promisify__;
|
|
20
|
+
writeFileSync: (file: fs.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView<ArrayBufferLike>, options?: fs.WriteFileOptions | undefined) => void;
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
23
|
+
/**
|
|
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.
|
|
28
|
+
*
|
|
29
|
+
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
30
|
+
* still be reading that dirent, and a reader has to see either the whole file
|
|
31
|
+
* that was there or the whole file replacing it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renameFileWithRetry(src: string, dest: string): void;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import util, { promisify } from 'node:util';
|
|
2
3
|
import gfs from 'graceful-fs';
|
|
4
|
+
const RENAME_RETRY_BUDGET_MS = 60_000;
|
|
5
|
+
const PERMISSION_DENIED_RETRY_BUDGET_MS = 1_000;
|
|
6
|
+
const RENAME_RETRY_BACKOFF_CAP_MS = 100;
|
|
7
|
+
const renameRetrySleepBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
3
8
|
export default {
|
|
4
9
|
chmod: promisify(gfs.chmod),
|
|
5
10
|
copyFile: promisify(gfs.copyFile),
|
|
@@ -41,4 +46,45 @@ function withEagainRetry(fn, maxRetries = 15) {
|
|
|
41
46
|
throw new Error('Unreachable');
|
|
42
47
|
};
|
|
43
48
|
}
|
|
49
|
+
/**
|
|
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.
|
|
54
|
+
*
|
|
55
|
+
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
56
|
+
* still be reading that dirent, and a reader has to see either the whole file
|
|
57
|
+
* that was there or the whole file replacing it.
|
|
58
|
+
*/
|
|
59
|
+
export function renameFileWithRetry(src, dest) {
|
|
60
|
+
const startedAt = Date.now();
|
|
61
|
+
let backoffMs = 0;
|
|
62
|
+
let budgetMs = RENAME_RETRY_BUDGET_MS;
|
|
63
|
+
for (;;) {
|
|
64
|
+
try {
|
|
65
|
+
fs.renameSync(src, dest);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
catch (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)
|
|
75
|
+
throw err;
|
|
76
|
+
if (backoffMs > 0)
|
|
77
|
+
Atomics.wait(renameRetrySleepBuffer, 0, 0, Math.min(backoffMs, remainingMs));
|
|
78
|
+
if (Date.now() - startedAt >= budgetMs)
|
|
79
|
+
throw err;
|
|
80
|
+
backoffMs = Math.min(backoffMs + 10, RENAME_RETRY_BACKOFF_CAP_MS);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function isTransientRenameError(err) {
|
|
85
|
+
return process.platform === 'win32' &&
|
|
86
|
+
util.types.isNativeError(err) &&
|
|
87
|
+
'code' in err &&
|
|
88
|
+
(err.code === 'EPERM' || err.code === 'EACCES' || err.code === 'EBUSY');
|
|
89
|
+
}
|
|
44
90
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fs.graceful-fs",
|
|
3
|
-
"version": "1100.
|
|
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
|
}
|