blun-king-cli 9.1.357 → 9.1.358
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/launcher-runtime.js +25 -3
- package/package.json +1 -1
package/bin/launcher-runtime.js
CHANGED
|
@@ -68,6 +68,7 @@ const RUNNING_UPDATE_RESUME_SESSION_ENV = 'BLUN_RUNNING_UPDATE_RESUME_SESSION_ID
|
|
|
68
68
|
const RUNTIME_READY_TIMEOUT_MS = 60_000;
|
|
69
69
|
const RUNNING_UPDATE_RECHECK_MS = 5 * 60_000;
|
|
70
70
|
const RUNNING_UPDATE_RECHECK_JITTER_MS = 2 * 60_000;
|
|
71
|
+
const RUNNING_UPDATE_ERROR_RETRY_MS = 10_000;
|
|
71
72
|
const RUNNING_UPDATE_STABILIZATION_MS = 2 * 60 * 1000;
|
|
72
73
|
|
|
73
74
|
function runningUpdateRecheckDelay(randomValue = Math.random()) {
|
|
@@ -87,6 +88,17 @@ function scheduleRunningUpdateRecheck(callback, options = {}) {
|
|
|
87
88
|
return timer;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
function runningUpdateFailureDetails(error) {
|
|
92
|
+
const safeField = (value, fallback) => typeof value === 'string'
|
|
93
|
+
&& /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value)
|
|
94
|
+
? value
|
|
95
|
+
: fallback;
|
|
96
|
+
return {
|
|
97
|
+
errorName: safeField(error?.name, 'Error'),
|
|
98
|
+
errorCode: safeField(error?.code, 'UNKNOWN'),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
function normalizeWindowsPath(value) {
|
|
91
103
|
return path.win32.normalize(value).replace(/\\+$/u, '').toLowerCase();
|
|
92
104
|
}
|
|
@@ -350,7 +362,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
350
362
|
if (typeof sharedHome !== 'string' || sharedHome.length === 0) return;
|
|
351
363
|
(options.stageRuntime || stageRuntime)(sharedHome, preparedTarget, stagedRuntimeOptions());
|
|
352
364
|
};
|
|
353
|
-
const scheduleNextPreparation = (child) => {
|
|
365
|
+
const scheduleNextPreparation = (child, scheduleOptions = {}) => {
|
|
354
366
|
clearRunningUpdatePoll();
|
|
355
367
|
if (supervisionCompleted || updateStarted) return;
|
|
356
368
|
runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
|
|
@@ -358,7 +370,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
358
370
|
refreshRunningUpdateMode();
|
|
359
371
|
if (automaticMode()) startPreparation(child);
|
|
360
372
|
else scheduleNextPreparation(child);
|
|
361
|
-
});
|
|
373
|
+
}, scheduleOptions);
|
|
362
374
|
};
|
|
363
375
|
const startPreparation = (child) => {
|
|
364
376
|
if (supervisionCompleted || updateStarted
|
|
@@ -417,7 +429,16 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
417
429
|
}).catch((error) => {
|
|
418
430
|
updateStarted = false;
|
|
419
431
|
options.onRunningUpdateError?.(error);
|
|
420
|
-
|
|
432
|
+
try {
|
|
433
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
434
|
+
event: 'prepare-failed',
|
|
435
|
+
runningVersion: readPackageVersionAt(packageRoot),
|
|
436
|
+
...runningUpdateFailureDetails(error),
|
|
437
|
+
}, { now: options.nowImpl });
|
|
438
|
+
} catch (recordError) {
|
|
439
|
+
options.onRunningUpdateError?.(recordError);
|
|
440
|
+
}
|
|
441
|
+
scheduleNextPreparation(child, { delayMs: RUNNING_UPDATE_ERROR_RETRY_MS });
|
|
421
442
|
});
|
|
422
443
|
};
|
|
423
444
|
const handleCoreMessage = (message, child) => {
|
|
@@ -931,6 +952,7 @@ async function runLauncher(options = {}) {
|
|
|
931
952
|
}
|
|
932
953
|
|
|
933
954
|
module.exports = {
|
|
955
|
+
RUNNING_UPDATE_ERROR_RETRY_MS,
|
|
934
956
|
RUNNING_UPDATE_RECHECK_JITTER_MS,
|
|
935
957
|
RUNNING_UPDATE_RECHECK_MS,
|
|
936
958
|
RUNNING_UPDATE_STABILIZATION_MS,
|