From fae1c3a3dee8e21b664edf638883f782bc2f7ace Mon Sep 17 00:00:00 2001 From: Sucukdeluxe <259325684+Sucukdeluxe@users.noreply.github.com> Date: Fri, 16 Oct 2026 05:37:26 +0200 Subject: [PATCH] Guard update recovery against live connection-status races --- lib/mcp-update.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mcp-update.js b/lib/mcp-update.js index 0960eff..6348775 100644 --- a/lib/mcp-update.js +++ b/lib/mcp-update.js @@ -14,6 +14,7 @@ class McpUpdate { this.writes = Promise.resolve(); this.task = null; this.resumeTask = null; + this.recoveryJobId = null; this.ready = false; } async load() { @@ -28,6 +29,7 @@ class McpUpdate { if (error.code !== 'ENOENT') throw new McpAccessError('UPDATE_STORE_UNAVAILABLE'); } this.ready = true; + this.recoveryJobId = this.active()?.id || null; } async save() { const data = JSON.stringify({ version: 1, jobs: this.jobs }); @@ -137,7 +139,7 @@ class McpUpdate { async recover({ rendererReady, connected }) { if (!this.ready || this.task || this.resumeTask || !rendererReady) return; const job = this.active(); - if (!job) return; + if (!job || job.id !== this.recoveryJobId) return; this.resumeTask = (async () => { if (job.phase === 'awaiting_reconnect') { if (connected) await this.phase(job, 'completed', { completedAt: Date.now(), reconnectedAt: Date.now() });