centralu 0.1.0-beta.48 → 0.1.0-beta.49
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/bin/serve-util.mjs +15 -4
- package/package.json +5 -5
package/bin/serve-util.mjs
CHANGED
|
@@ -43,23 +43,34 @@ const BUSY_CODES = new Set(['EPERM', 'EBUSY', 'EACCES'])
|
|
|
43
43
|
/**
|
|
44
44
|
* `rename`, tried again for up to `budgetMs` while the system refuses it because someone has the target open (#1041;
|
|
45
45
|
* `retry`: Windows only, `renameWaitsForReaders`). With `retry` off, and for any other error, it is one try. Backs off 10, 20, 40 ... 200 ms between tries; the last
|
|
46
|
-
* error is thrown when the budget is spent.
|
|
46
|
+
* error is thrown when the budget is spent. The budget is the time it waited, not the clock's: a process the system
|
|
47
|
+
* held for a while (a loaded runner, a laptop going to sleep) holds the reader up as long, and the clock would have
|
|
48
|
+
* spent the whole budget on that pause and given up on the first refusal after it, before the reader could let go. The time the renames themselves blocked is counted by the clock, apart, and ends it at twice the budget: a
|
|
49
|
+
* rename that blocks (a slow virus scanner or filter driver) would otherwise get every try, each as slow as the first. A
|
|
50
|
+
* pause during a sleep is in neither count.
|
|
47
51
|
*
|
|
48
52
|
* `mayTry`, when given, is asked before every try, the first too, and a false answer ends it with its error (#1405
|
|
49
53
|
* review): a writer under a lock checks there that the lock is still its own, so a retry seconds later cannot land a
|
|
50
54
|
* write after another writer took the lock over.
|
|
51
55
|
*/
|
|
52
56
|
export function renameRetrying(from, to, { retry = renameWaitsForReaders(), rename = renameSync, sleep = sleepSync, budgetMs = 5_000, now = Date.now, mayTry = null } = {}) {
|
|
53
|
-
|
|
57
|
+
let waited = 0
|
|
58
|
+
let blocked = 0
|
|
54
59
|
for (let delay = 10; ; delay = Math.min(delay * 2, 200)) {
|
|
55
60
|
const refusal = mayTry?.()
|
|
56
61
|
if (refusal) throw refusal
|
|
57
62
|
try {
|
|
58
|
-
|
|
63
|
+
const t0 = now()
|
|
64
|
+
try {
|
|
65
|
+
return rename(from, to)
|
|
66
|
+
} finally {
|
|
67
|
+
blocked += now() - t0
|
|
68
|
+
}
|
|
59
69
|
} catch (e) {
|
|
60
|
-
if (!retry || !BUSY_CODES.has(e?.code) ||
|
|
70
|
+
if (!retry || !BUSY_CODES.has(e?.code) || waited + delay > budgetMs || blocked > 2 * budgetMs) throw e
|
|
61
71
|
}
|
|
62
72
|
sleep(delay)
|
|
73
|
+
waited += delay
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "centralu",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.49",
|
|
4
4
|
"description": "Run, watch and steer several Claude Code and Codex CLI sessions from one window",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ijun17",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"win32"
|
|
39
39
|
],
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@centralu/darwin-arm64": "0.1.0-beta.
|
|
42
|
-
"@centralu/linux-arm64": "0.1.0-beta.
|
|
43
|
-
"@centralu/linux-x64": "0.1.0-beta.
|
|
44
|
-
"@centralu/win32-x64": "0.1.0-beta.
|
|
41
|
+
"@centralu/darwin-arm64": "0.1.0-beta.49",
|
|
42
|
+
"@centralu/linux-arm64": "0.1.0-beta.49",
|
|
43
|
+
"@centralu/linux-x64": "0.1.0-beta.49",
|
|
44
|
+
"@centralu/win32-x64": "0.1.0-beta.49"
|
|
45
45
|
}
|
|
46
46
|
}
|