@livedesk/hub 0.1.64 → 0.1.65
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/package.json +1 -1
- package/src/live-desk-update.js +32 -17
package/package.json
CHANGED
package/src/live-desk-update.js
CHANGED
|
@@ -66,9 +66,11 @@ export function isVersionAtLeast(candidate, required) {
|
|
|
66
66
|
return !!cleanVersion(candidate) && !!cleanVersion(required) && compareVersions(candidate, required) >= 0;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
function isDedicatedBootstrapFailure(value) {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
function isDedicatedBootstrapFailure(value) {
|
|
70
|
+
const failure = String(value || '').trim();
|
|
71
|
+
return /^Update worker exited before terminal proof\b/i.test(failure)
|
|
72
|
+
|| failure === 'invalid-update-host-environment-entry';
|
|
73
|
+
}
|
|
72
74
|
|
|
73
75
|
function encodePowerShell(value) {
|
|
74
76
|
return Buffer.from(String(value || ''), 'utf16le').toString('base64');
|
|
@@ -451,16 +453,29 @@ export function createLiveDeskUpdateManager({
|
|
|
451
453
|
return true;
|
|
452
454
|
};
|
|
453
455
|
|
|
454
|
-
const dispatchTarget = (target, device, options = {}) => {
|
|
455
|
-
const dispatchedAtEpochMs = now();
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
456
|
+
const dispatchTarget = (target, device, options = {}) => {
|
|
457
|
+
const dispatchedAtEpochMs = now();
|
|
458
|
+
const requestedDeadlineEpochMs = Date.parse(String(options.deadlineAt || ''));
|
|
459
|
+
const usesExistingDeadline = Number.isFinite(requestedDeadlineEpochMs)
|
|
460
|
+
&& requestedDeadlineEpochMs > 0;
|
|
461
|
+
const remainingExistingDeadlineMs = requestedDeadlineEpochMs - dispatchedAtEpochMs;
|
|
462
|
+
if (usesExistingDeadline && remainingExistingDeadlineMs < 10_000) {
|
|
463
|
+
target.state = 'failed';
|
|
464
|
+
target.error = 'client-update-deadline-insufficient';
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
const requestedTimeoutMs = usesExistingDeadline
|
|
468
|
+
? Math.min(effectiveTargetTimeoutMs, remainingExistingDeadlineMs)
|
|
469
|
+
: Math.max(
|
|
470
|
+
10_000,
|
|
471
|
+
Math.min(
|
|
472
|
+
effectiveTargetTimeoutMs,
|
|
473
|
+
Number(options.updateTimeoutMs) || effectiveTargetTimeoutMs
|
|
474
|
+
)
|
|
475
|
+
);
|
|
476
|
+
const updateDeadlineEpochMs = usesExistingDeadline
|
|
477
|
+
? requestedDeadlineEpochMs
|
|
478
|
+
: dispatchedAtEpochMs + requestedTimeoutMs;
|
|
464
479
|
const dispatchedSessionId = String(device?.sessionId || '').trim();
|
|
465
480
|
if (!dispatchedSessionId) {
|
|
466
481
|
target.state = 'failed';
|
|
@@ -800,10 +815,10 @@ export function createLiveDeskUpdateManager({
|
|
|
800
815
|
target.error = '';
|
|
801
816
|
let retryResult;
|
|
802
817
|
try {
|
|
803
|
-
retryResult = dispatchTarget(target, retryDevice, {
|
|
804
|
-
forceLegacy: true,
|
|
805
|
-
|
|
806
|
-
});
|
|
818
|
+
retryResult = dispatchTarget(target, retryDevice, {
|
|
819
|
+
forceLegacy: true,
|
|
820
|
+
deadlineAt: target.deadlineAt
|
|
821
|
+
});
|
|
807
822
|
} catch (error) {
|
|
808
823
|
target.error = String(error?.message || error || 'client-update-bootstrap-retry-failed').slice(0, 500);
|
|
809
824
|
retryResult = false;
|