diff --git a/packages/kilo-vscode/src/kiloclaw/kilo-chat-client.ts b/packages/kilo-vscode/src/kiloclaw/kilo-chat-client.ts index 51ddb59ee4d..41ee4dd59d3 100644 --- a/packages/kilo-vscode/src/kiloclaw/kilo-chat-client.ts +++ b/packages/kilo-vscode/src/kiloclaw/kilo-chat-client.ts @@ -128,11 +128,12 @@ export class KiloChatClient { }) const next = prev.then(send, send) this.sendQueues.set(req.conversationId, next) - void next.finally(() => { + const cleanup = () => { if (this.sendQueues.get(req.conversationId) === next) { this.sendQueues.delete(req.conversationId) } - }) + } + void next.then(cleanup, cleanup) return next } diff --git a/packages/opencode/src/kilocode/claw/kilo-chat-client.ts b/packages/opencode/src/kilocode/claw/kilo-chat-client.ts index 7b5c73d7391..af6cdf448b4 100644 --- a/packages/opencode/src/kilocode/claw/kilo-chat-client.ts +++ b/packages/opencode/src/kilocode/claw/kilo-chat-client.ts @@ -119,11 +119,12 @@ export class KiloChatClient { }) const next = prev.then(send, send) this.sendQueues.set(req.conversationId, next) - void next.finally(() => { + const cleanup = () => { if (this.sendQueues.get(req.conversationId) === next) { this.sendQueues.delete(req.conversationId) } - }) + } + void next.then(cleanup, cleanup) return next }