@alwaysmeticulous/downloading-helpers 2.264.0 → 2.264.2
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.
|
@@ -6,6 +6,44 @@ const path_1 = require("path");
|
|
|
6
6
|
const common_1 = require("@alwaysmeticulous/common");
|
|
7
7
|
const luxon_1 = require("luxon");
|
|
8
8
|
const proper_lockfile_1 = require("proper-lockfile");
|
|
9
|
+
/**
|
|
10
|
+
* proper-lockfile v4 uses a timer that periodically stat()s the lock file to
|
|
11
|
+
* keep it fresh. There's a race where the timer dispatches an async stat() just
|
|
12
|
+
* before releaseLock() calls clearTimeout + removes the lock file. The
|
|
13
|
+
* in-flight stat() then returns ENOENT, and proper-lockfile's default
|
|
14
|
+
* onCompromised handler throws — from a timer callback, so it becomes an
|
|
15
|
+
* uncaught exception that crashes the process.
|
|
16
|
+
*
|
|
17
|
+
* The lock IS released correctly; the error is purely internal to the library's
|
|
18
|
+
* timer cleanup. We use onCompromised + a releasing flag to swallow this
|
|
19
|
+
* specific case while still propagating genuine lock compromises.
|
|
20
|
+
*/
|
|
21
|
+
const acquireLockSafely = async (target, options) => {
|
|
22
|
+
let releasing = false;
|
|
23
|
+
const releaseLock = await (0, proper_lockfile_1.lock)(target, {
|
|
24
|
+
...options,
|
|
25
|
+
onCompromised: (err) => {
|
|
26
|
+
if (releasing && isLockReleaseRaceConditionError(err)) {
|
|
27
|
+
const logger = (0, common_1.initLogger)();
|
|
28
|
+
logger.warn("Ignoring benign ENOENT error during lock release (proper-lockfile timer race condition)");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
throw err;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return async () => {
|
|
35
|
+
releasing = true;
|
|
36
|
+
await releaseLock();
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const isLockReleaseRaceConditionError = (error) => {
|
|
40
|
+
if (!(error instanceof Error))
|
|
41
|
+
return false;
|
|
42
|
+
const nodeError = error;
|
|
43
|
+
// proper-lockfile mutates the original ENOENT error via Object.assign,
|
|
44
|
+
// overwriting .code to ECOMPROMISED before calling onCompromised.
|
|
45
|
+
return nodeError.code === "ECOMPROMISED" && error.message.includes("ENOENT");
|
|
46
|
+
};
|
|
9
47
|
const sanitizeFilename = (filename) => {
|
|
10
48
|
return filename.replace(/[^a-zA-Z0-9]/g, "_");
|
|
11
49
|
};
|
|
@@ -56,13 +94,10 @@ const waitToAcquireLockOnFile = async (filePath) => {
|
|
|
56
94
|
// Note: we don't delete the lock directory afterwards because doing so without creating race-conditions is tricky
|
|
57
95
|
const lockDirectory = `${filePath}.lock-target`;
|
|
58
96
|
await (0, promises_1.mkdir)(lockDirectory, { recursive: true });
|
|
59
|
-
|
|
97
|
+
return acquireLockSafely(lockDirectory, {
|
|
60
98
|
retries: LOCK_RETRY_OPTIONS,
|
|
61
99
|
lockfilePath: `${filePath}.lock`,
|
|
62
100
|
});
|
|
63
|
-
return async () => {
|
|
64
|
-
await releaseLock();
|
|
65
|
-
};
|
|
66
101
|
};
|
|
67
102
|
exports.waitToAcquireLockOnFile = waitToAcquireLockOnFile;
|
|
68
103
|
const fileExists = (filePath) => (0, promises_1.access)(filePath)
|
|
@@ -70,7 +105,7 @@ const fileExists = (filePath) => (0, promises_1.access)(filePath)
|
|
|
70
105
|
.catch(() => false);
|
|
71
106
|
exports.fileExists = fileExists;
|
|
72
107
|
const waitToAcquireLockOnDirectory = (directoryPath) => {
|
|
73
|
-
return (
|
|
108
|
+
return acquireLockSafely(directoryPath, {
|
|
74
109
|
retries: LOCK_RETRY_OPTIONS,
|
|
75
110
|
lockfilePath: (0, path_1.join)(directoryPath, "dir.lock"),
|
|
76
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-data.utils.js","sourceRoot":"","sources":["../../src/file-downloads/local-data.utils.ts"],"names":[],"mappings":";;;AAAA,0CAAiE;AACjE,+BAAqC;AACrC,qDAAsD;AACtD,iCAA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AE,CAAC,cAAc,CAAC;IACpE,mEAAmE;IACnE,SAAS,EAAE,IAAI;CAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysmeticulous/downloading-helpers",
|
|
3
|
-
"version": "2.264.
|
|
3
|
+
"version": "2.264.2",
|
|
4
4
|
"description": "Helper utilities for downloading files & scripts required to execute replays",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@alwaysmeticulous/api": "2.264.0",
|
|
24
|
-
"@alwaysmeticulous/client": "2.264.
|
|
24
|
+
"@alwaysmeticulous/client": "2.264.1",
|
|
25
25
|
"@alwaysmeticulous/common": "2.264.0",
|
|
26
26
|
"axios": "^1.7.9",
|
|
27
27
|
"axios-retry": "^4.5.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"bugs": {
|
|
57
57
|
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e5ed817a9f004248d57f7e83837b5b4e0fdc7d81"
|
|
60
60
|
}
|