@tangle-network/sdk-cli-runner 0.3.16 → 0.3.17
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/dist/index.d.mts +2 -1
- package/dist/index.mjs +19 -13
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -343,7 +343,8 @@ interface HeldSpareLetFinish {
|
|
|
343
343
|
/**
|
|
344
344
|
* How long before the discard the lock it found was last written. One
|
|
345
345
|
* written before the spare started is not the spare's: it was cloned into
|
|
346
|
-
* this HOME with a snapshot, or an earlier process left it.
|
|
346
|
+
* this HOME with a snapshot, or an earlier process left it. Undefined for
|
|
347
|
+
* a spare not shown frozen, and for a lock that could not be read.
|
|
347
348
|
*/
|
|
348
349
|
readonly lockAgeMs: number | undefined;
|
|
349
350
|
readonly spareAgeMs: number;
|
package/dist/index.mjs
CHANGED
|
@@ -1628,8 +1628,11 @@ function createDeferredParser() {
|
|
|
1628
1628
|
/** How long a spare no turn adopted keeps its process. */
|
|
1629
1629
|
const HELD_SPARE_IDLE_MS = 12e4;
|
|
1630
1630
|
/**
|
|
1631
|
-
* How long a stopped spare has to exit after SIGTERM before
|
|
1632
|
-
* Its HOME stays taken, and a turn that waits for it waits, until
|
|
1631
|
+
* How long a stopped spare has to exit after SIGTERM before the registry
|
|
1632
|
+
* kills it. Its HOME stays taken, and a turn that waits for it waits, until
|
|
1633
|
+
* it exits. A spare launched with its controller's signal is killed sooner:
|
|
1634
|
+
* aborting the controller starts the runner's own escalation, 1 s
|
|
1635
|
+
* (child-killer.ts), and this timer is the backstop for one that was not.
|
|
1633
1636
|
*/
|
|
1634
1637
|
const HELD_SPARE_STOP_GRACE_MS = 2e3;
|
|
1635
1638
|
/** How long a discard waits to see a killed spare exit before it fails. */
|
|
@@ -1677,21 +1680,24 @@ function createHeldSpareRegistry(options = {}) {
|
|
|
1677
1680
|
return true;
|
|
1678
1681
|
};
|
|
1679
1682
|
/**
|
|
1680
|
-
* The
|
|
1681
|
-
*
|
|
1682
|
-
*
|
|
1683
|
+
* The lock a frozen spare holds, if it holds one: its age, or "unreadable"
|
|
1684
|
+
* for one that cannot be read (taken to be held). A lock that goes while
|
|
1685
|
+
* the spare cannot run is another process's (a tenant's own turn in that
|
|
1686
|
+
* HOME, writing); one that stays is taken to be the spare's.
|
|
1683
1687
|
*/
|
|
1684
|
-
const
|
|
1688
|
+
const heldLock = async (spare) => {
|
|
1685
1689
|
const paths = options.locks?.(spare) ?? [];
|
|
1686
|
-
const
|
|
1687
|
-
for (const path of paths) {
|
|
1690
|
+
const look = () => {
|
|
1691
|
+
for (const path of paths) try {
|
|
1688
1692
|
const lock = statSync(path, { throwIfNoEntry: false });
|
|
1689
1693
|
if (lock) return Date.now() - lock.mtimeMs;
|
|
1694
|
+
} catch {
|
|
1695
|
+
return "unreadable";
|
|
1690
1696
|
}
|
|
1691
1697
|
};
|
|
1692
1698
|
const until = performance.now() + HELD_SPARE_LOCK_SETTLE_MS;
|
|
1693
|
-
for (let
|
|
1694
|
-
if (performance.now() >= until) return
|
|
1699
|
+
for (let lock = look(); lock !== void 0; lock = look()) {
|
|
1700
|
+
if (performance.now() >= until) return lock;
|
|
1695
1701
|
await setTimeout$1(HELD_SPARE_LOCK_POLL_MS);
|
|
1696
1702
|
}
|
|
1697
1703
|
};
|
|
@@ -1709,9 +1715,9 @@ function createHeldSpareRegistry(options = {}) {
|
|
|
1709
1715
|
const discardOne = async (spare) => {
|
|
1710
1716
|
const running = retire(spare);
|
|
1711
1717
|
const frozen = options.locks === void 0 || await freeze(spare);
|
|
1712
|
-
const
|
|
1718
|
+
const lock = frozen ? await heldLock(spare) : void 0;
|
|
1713
1719
|
if (running) spare.controller.abort();
|
|
1714
|
-
if (frozen &&
|
|
1720
|
+
if (frozen && lock === void 0) {
|
|
1715
1721
|
spare.process.kill("SIGKILL");
|
|
1716
1722
|
return { boundMs: HELD_SPARE_EXIT_BOUND_MS };
|
|
1717
1723
|
}
|
|
@@ -1722,7 +1728,7 @@ function createHeldSpareRegistry(options = {}) {
|
|
|
1722
1728
|
letFinish: {
|
|
1723
1729
|
home: spare.home,
|
|
1724
1730
|
frozen,
|
|
1725
|
-
lockAgeMs,
|
|
1731
|
+
lockAgeMs: typeof lock === "number" ? lock : void 0,
|
|
1726
1732
|
spareAgeMs: performance.now() - spare.startedAt
|
|
1727
1733
|
}
|
|
1728
1734
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sdk-cli-runner",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Generic CLI process spawning with stdin/stdout streaming and JSONL parsing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"registry": "https://registry.npmjs.org"
|
|
27
27
|
},
|
|
28
28
|
"tangleRelease": {
|
|
29
|
-
"sourceSha": "
|
|
30
|
-
"mergedAt": "2026-11-22T22:
|
|
29
|
+
"sourceSha": "e71746bf3cf7d504d76e0e24659e55501b42a175",
|
|
30
|
+
"mergedAt": "2026-11-22T22:31:59-08:00"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsdown",
|