@zixt/host 0.0.82 → 0.0.83
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.js +34 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import { homedir as homedir3 } from "node:os";
|
|
|
31
31
|
// package.json
|
|
32
32
|
var package_default = {
|
|
33
33
|
name: "@zixt/host",
|
|
34
|
-
version: "0.0.
|
|
34
|
+
version: "0.0.83",
|
|
35
35
|
type: "module",
|
|
36
36
|
exports: {
|
|
37
37
|
".": "./src/client.ts",
|
|
@@ -25446,6 +25446,9 @@ var DO_NOT_RESTART_EXIT_CODE = 64;
|
|
|
25446
25446
|
var RESTART_BACKOFF_MS = 2e3;
|
|
25447
25447
|
var MAX_RESTART_BACKOFF_MS = 6e4;
|
|
25448
25448
|
var CRASH_STREAK_RESET_MS = 6e4;
|
|
25449
|
+
function streakBackoffMs(streak) {
|
|
25450
|
+
return Math.min(MAX_RESTART_BACKOFF_MS, RESTART_BACKOFF_MS * 2 ** Math.min(streak - 1, 10));
|
|
25451
|
+
}
|
|
25449
25452
|
var RELEASE_PROBATION_MS = 5 * 6e4;
|
|
25450
25453
|
var FAST_UPDATE_EXIT_MS = 1e4;
|
|
25451
25454
|
var STOP_GRACE_MS = 3e4;
|
|
@@ -25496,6 +25499,23 @@ function versionsRoot() {
|
|
|
25496
25499
|
function npmCommand(platform = process.platform) {
|
|
25497
25500
|
return platform === "win32" ? "npm.cmd" : "npm";
|
|
25498
25501
|
}
|
|
25502
|
+
async function resolveInstallerCommand(options = {}) {
|
|
25503
|
+
const platform = options.platform ?? process.platform;
|
|
25504
|
+
const command = npmCommand(platform);
|
|
25505
|
+
if (platform !== "win32") return command;
|
|
25506
|
+
const execPath = options.execPath ?? process.execPath;
|
|
25507
|
+
const resolution = {
|
|
25508
|
+
platform,
|
|
25509
|
+
...options.searchPath !== void 0 ? { searchPath: options.searchPath } : {}
|
|
25510
|
+
};
|
|
25511
|
+
return (
|
|
25512
|
+
// npm ships beside the `node` running this process, and that copy is the
|
|
25513
|
+
// one matching it. A per-user Scheduled Task may carry no npm on PATH.
|
|
25514
|
+
await resolveTrustedCliCommand(join8(dirname4(execPath), command), resolution) ?? await resolveTrustedCliCommand(command, resolution) ?? // Nothing resolved: keep the previous behaviour, so a Machine without npm
|
|
25515
|
+
// fails one install rather than changing how failure is handled.
|
|
25516
|
+
command
|
|
25517
|
+
);
|
|
25518
|
+
}
|
|
25499
25519
|
function windowsInstallerCommandLine(command, args) {
|
|
25500
25520
|
return [command, ...args].map(quoteForCmd).join(" ");
|
|
25501
25521
|
}
|
|
@@ -25788,12 +25808,12 @@ var InstallerContainmentError = class extends Error {
|
|
|
25788
25808
|
async function installRelease(version2, options = {}) {
|
|
25789
25809
|
if (!VERSION_DIR.test(version2)) return null;
|
|
25790
25810
|
const platform = options.platform ?? process.platform;
|
|
25791
|
-
const installerCommand = options.installerCommand ?? npmCommand(platform);
|
|
25792
25811
|
const root = options.root ?? versionsRoot();
|
|
25793
25812
|
const prefix = join8(root, version2);
|
|
25794
25813
|
const entry = installedReleaseEntry(version2, root);
|
|
25795
25814
|
if (await validReleaseAtPrefix(prefix, version2)) return entry;
|
|
25796
25815
|
if (options.signal?.aborted) return null;
|
|
25816
|
+
const installerCommand = options.installerCommand ?? await resolveInstallerCommand({ platform });
|
|
25797
25817
|
await mkdir5(root, { recursive: true, mode: 448 });
|
|
25798
25818
|
const staging = join8(root, `.install-${version2}-${process.pid}-${crypto.randomUUID()}`);
|
|
25799
25819
|
const quarantine = join8(root, `.invalid-${version2}-${process.pid}-${crypto.randomUUID()}`);
|
|
@@ -26602,6 +26622,7 @@ async function superviseHost(options = {}) {
|
|
|
26602
26622
|
announceShutdown = resolve18;
|
|
26603
26623
|
});
|
|
26604
26624
|
const attempted = /* @__PURE__ */ new Set();
|
|
26625
|
+
let unsatisfiableUpdates = 0;
|
|
26605
26626
|
const waitOrShutdown = async (ms) => {
|
|
26606
26627
|
if (shuttingDown2) return false;
|
|
26607
26628
|
if (!customDelay) {
|
|
@@ -26622,11 +26643,7 @@ async function superviseHost(options = {}) {
|
|
|
26622
26643
|
const waitAfterCrash = async (runtimeMs) => {
|
|
26623
26644
|
if (runtimeMs >= CRASH_STREAK_RESET_MS) consecutiveCrashes = 0;
|
|
26624
26645
|
consecutiveCrashes++;
|
|
26625
|
-
|
|
26626
|
-
MAX_RESTART_BACKOFF_MS,
|
|
26627
|
-
RESTART_BACKOFF_MS * 2 ** Math.min(consecutiveCrashes - 1, 10)
|
|
26628
|
-
);
|
|
26629
|
-
return waitOrShutdown(backoff);
|
|
26646
|
+
return waitOrShutdown(streakBackoffMs(consecutiveCrashes));
|
|
26630
26647
|
};
|
|
26631
26648
|
const cleanupExitedWorker = async (exitedChild, childExited, workerBoundary, containment) => {
|
|
26632
26649
|
for (let attempt = 1; attempt <= CLEANUP_ATTEMPTS2; attempt++) {
|
|
@@ -26989,10 +27006,15 @@ async function superviseHost(options = {}) {
|
|
|
26989
27006
|
consecutiveCrashes = 0;
|
|
26990
27007
|
if (orderlyValidatedBoundary) rollbackCandidate = null;
|
|
26991
27008
|
const target = await published();
|
|
27009
|
+
let updateLanded = false;
|
|
26992
27010
|
if (target === null) {
|
|
26993
27011
|
log2(
|
|
26994
27012
|
"Zixt Host: a newer release was reported but the registry is unreachable; staying on the current version"
|
|
26995
27013
|
);
|
|
27014
|
+
} else if (target === command.version) {
|
|
27015
|
+
log2(
|
|
27016
|
+
`Zixt Host: this Machine already runs the newest published release (${target}), so an update cannot satisfy the cloud; waiting for a newer one`
|
|
27017
|
+
);
|
|
26996
27018
|
} else if (attempted.has(target)) {
|
|
26997
27019
|
log2(`Zixt Host: already running ${target}; ignoring a repeated update request`);
|
|
26998
27020
|
} else {
|
|
@@ -27066,6 +27088,7 @@ async function superviseHost(options = {}) {
|
|
|
27066
27088
|
}
|
|
27067
27089
|
rollbackCandidate = { failedVersion: target, command: fallback };
|
|
27068
27090
|
command = { entry, version: target };
|
|
27091
|
+
updateLanded = true;
|
|
27069
27092
|
if (reloadAfterActivation) return SUPERVISOR_RELOAD_EXIT_CODE;
|
|
27070
27093
|
if (releaseStore) {
|
|
27071
27094
|
const probation = durableState("probation", target, fallback.version);
|
|
@@ -27093,7 +27116,10 @@ async function superviseHost(options = {}) {
|
|
|
27093
27116
|
log2(`Zixt Host: could not install ${target}; staying on the current version`);
|
|
27094
27117
|
}
|
|
27095
27118
|
}
|
|
27096
|
-
|
|
27119
|
+
unsatisfiableUpdates = updateLanded ? 0 : unsatisfiableUpdates + 1;
|
|
27120
|
+
if (unsatisfiableUpdates > 0) {
|
|
27121
|
+
if (!await waitOrShutdown(streakBackoffMs(unsatisfiableUpdates))) return 0;
|
|
27122
|
+
} else if (now() - startedAt < FAST_UPDATE_EXIT_MS && !await waitOrShutdown(RESTART_BACKOFF_MS)) {
|
|
27097
27123
|
return 0;
|
|
27098
27124
|
}
|
|
27099
27125
|
if (shuttingDown2) return 0;
|