From cf20e76dd99d69b5dcaf5e8efaad814d61fbd5e2 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Sun, 26 Apr 2026 21:47:26 -0400 Subject: [PATCH] fix(daemon): skip checkpoint timer for pre-v4 legacy daemons Legacy daemons (protocol <4) don't support the getSnapshot RPC, so the checkpoint timer fires every 5s and logs noisy DaemonProtocolError warnings. Store the protocol version and gate startCheckpointTimer on supportsCheckpoints. Legacy adapters still have historyPath for cleanup (close/exit mark meta.json as ended) but won't attempt checkpoint RPCs. Co-authored-by: Orca --- src/main/daemon/daemon-pty-adapter.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/daemon/daemon-pty-adapter.ts b/src/main/daemon/daemon-pty-adapter.ts index cd59405ab..7d815c131 100644 --- a/src/main/daemon/daemon-pty-adapter.ts +++ b/src/main/daemon/daemon-pty-adapter.ts @@ -8,11 +8,12 @@ import { DaemonClient } from './client' import { HistoryManager } from './history-manager' import { HistoryReader } from './history-reader' import { supportsPtyStartupBarrier } from './shell-ready' -import type { - CreateOrAttachResult, - DaemonEvent, - GetSnapshotResult, - ListSessionsResult +import { + PROTOCOL_VERSION, + type CreateOrAttachResult, + type DaemonEvent, + type GetSnapshotResult, + type ListSessionsResult } from './types' import type { IPtyProvider, PtySpawnOptions, PtySpawnResult } from '../providers/types' @@ -64,6 +65,9 @@ export class DaemonPtyAdapter implements IPtyProvider { private activeSessionIds = new Set() private checkpointInterval: ReturnType | null = null private checkpointInFlight: Promise | null = null + // Why: checkpoint-based persistence requires the getSnapshot RPC (v4+). + // Legacy daemons reject it, causing noisy log spam every 5 seconds. + private supportsCheckpoints: boolean private static CHECKPOINT_INTERVAL_MS = 5_000 constructor(opts: DaemonPtyAdapterOptions) { @@ -75,6 +79,7 @@ export class DaemonPtyAdapter implements IPtyProvider { this.historyManager = opts.historyPath ? new HistoryManager(opts.historyPath) : null this.historyReader = opts.historyPath ? new HistoryReader(opts.historyPath) : null this.respawnFn = opts.respawn ?? null + this.supportsCheckpoints = (opts.protocolVersion ?? PROTOCOL_VERSION) >= 4 } getHistoryManager(): HistoryManager | null { @@ -441,7 +446,7 @@ export class DaemonPtyAdapter implements IPtyProvider { } private startCheckpointTimer(): void { - if (this.checkpointInterval || !this.historyManager) { + if (this.checkpointInterval || !this.historyManager || !this.supportsCheckpoints) { return } this.checkpointInterval = setInterval(() => {