Skip to content

The agent that grows with you

test(updater): cover handoff marker edge cases

fangliquan065c8bd6c0bd
diff --git a/apps/bootstrap-installer/src-tauri/src/update.rs b/apps/bootstrap-installer/src-tauri/src/update.rs
index 034f82f497f..df2f0a1bc8d 100644
--- a/apps/bootstrap-installer/src-tauri/src/update.rs
+++ b/apps/bootstrap-installer/src-tauri/src/update.rs
@@ -201,6 +201,8 @@ impl UpdateMarkerGuard {
let pid = std::process::id();
if let Some(owner) = live_marker_owner(&path) {
if owner.pid == pid {
+ // Repeated acquisition in this process is intentionally
+ // re-entrant because the desktop may have pre-written our pid.
// The desktop races ahead and pre-writes our pid. Adopt that
// claim verbatim: rewriting started_at here lets retries reset
// a wedged updater's age before the stale ceiling can clear it.
diff --git a/apps/desktop/electron/update-handoff-marker.test.ts b/apps/desktop/electron/update-handoff-marker.test.ts
index 9bf1151437c..52db0d2e537 100644
--- a/apps/desktop/electron/update-handoff-marker.test.ts
+++ b/apps/desktop/electron/update-handoff-marker.test.ts
@@ -32,10 +32,11 @@ function runPosix(installRoot: string, startedAt?: string) {
env.HERMES_UPDATE_STARTED_AT = startedAt
}
- return spawnSync('/bin/bash', [POSIX_SCRIPT, '--install-root', installRoot, '--self-test-marker'], {
- env,
- encoding: 'utf8'
- })
+ return spawnSync(
+ '/bin/bash',
+ [POSIX_SCRIPT, '--daemonized', '--install-root', installRoot, '--self-test-marker'],
+ { env, encoding: 'utf8' }
+ )
}
function runWindows(installRoot: string, startedAt?: string) {
@@ -83,6 +84,17 @@ function assertScriptHandoff(run: (installRoot: string, startedAt?: string) => R
markerStartedAt(refreshed.home) >= before && markerStartedAt(refreshed.home) <= after,
'an invalid hand-off timestamp must start a fresh claim'
)
+
+ const oversized = sandbox('oversized')
+ const oversizedBefore = Math.floor(Date.now() / 1000)
+ const oversizedResult = run(oversized.installRoot, '99999999999999999999')
+ const oversizedAfter = Math.floor(Date.now() / 1000)
+
+ assert.equal(oversizedResult.status, 0, String(oversizedResult.stderr || oversizedResult.stdout))
+ assert.ok(
+ markerStartedAt(oversized.home) >= oversizedBefore && markerStartedAt(oversized.home) <= oversizedAfter,
+ 'an oversized hand-off timestamp must start a fresh claim'
+ )
}
test.skipIf(process.platform === 'win32')('POSIX hand-off preserves the Desktop marker acquisition time', () => {