Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-ssh): 服务器 rekey 后不再把已就绪主机打回认证中 (#5717)
FicoWang5bef1869935d
diff --git a/packages/maker-remote-ssh/src/RemoteHost.ts b/packages/maker-remote-ssh/src/RemoteHost.tsindex 760871866c..736e3c5ca2 100644--- a/packages/maker-remote-ssh/src/RemoteHost.ts+++ b/packages/maker-remote-ssh/src/RemoteHost.ts@@ -1345,9 +1345,12 @@ export class RemoteHost {// ssh2 emits 'handshake' before 'ready' — repurpose to advance state// so renderer can show "authenticating" instead of staying on- // "connecting" throughout auth.+ // "connecting" throughout auth. ssh2 also emits it after every later+ // key exchange (server-initiated rekey, e.g. Dropbear every 8h) without+ // a following 'ready', so only the attempt's first, unsettled handshake+ // may move the status; a rekey must leave a ready host ready (#5715).client.on('handshake', () => {- if (isCurrentAttempt()) this.setStatus('authenticating');+ if (!settled && isCurrentAttempt()) this.setStatus('authenticating');});client.on('ready', onReady);client.on('error', onError);diff --git a/packages/maker-remote-ssh/src/__tests__/remoteHostConnectRace.test.ts b/packages/maker-remote-ssh/src/__tests__/remoteHostConnectRace.test.tsindex 51031a6602..8de2ab8ac6 100644--- a/packages/maker-remote-ssh/src/__tests__/remoteHostConnectRace.test.ts+++ b/packages/maker-remote-ssh/src/__tests__/remoteHostConnectRace.test.ts@@ -281,6 +281,37 @@ describe('RemoteHost arm/disconnect race', () => {expect(host.snapshot().lastError).toBeUndefined();});+ it('a server rekey after ready keeps the host ready and connect() resolves (#5715)', async () => {+ h.client = null;+ const host = new RemoteHost(HOST_CONFIG, { logger: noopLogger });++ const connectP = host.connect();+ await flush();+ const client = h.client!;+ expect(client).toBeTruthy();+ // First key exchange of the attempt still advances to authenticating.+ client.emit('handshake');+ expect(host.getStatus()).toBe('authenticating');+ client.emit('ready');+ await connectP;+ expect(host.getStatus()).toBe('ready');+ const clientsBefore = h.createClient.mock.calls.length;++ // ssh2 emits 'handshake' again for every later key exchange (Dropbear+ // rekeys every 8h) and never re-emits 'ready'.+ client.emit('handshake');+ expect(host.getStatus()).toBe('ready');++ // Before the fix these joined waitForTerminal() with no attempt in+ // flight and hung until a manual disconnect.+ const joined = Promise.all([host.connect(), host.connect()]);+ const timedOut = new Promise((_, reject) => setTimeout(() => reject(new Error('connect hung after rekey')), 500));+ await expect(Promise.race([joined, timedOut])).resolves.toBeDefined();+ expect(host.getStatus()).toBe('ready');+ expect(h.createClient.mock.calls.length).toBe(clientsBefore);+ expect(client.ended).toBe(false);+ });+it('disconnect before SSH ready invalidates late client events', async () => {h.client = null;const host = new RemoteHost(HOST_CONFIG, { logger: noopLogger });