fix(server): close query stream before interrupt/return in claude agent

Call query.close() before awaiting interrupt/return to ensure the
stream is properly torn down on session close and query restart.
This commit is contained in:
Mohamed Boudra
2026-03-23 22:04:37 +07:00
parent d4735edd45
commit 771acd11a1
@@ -1611,6 +1611,7 @@ class ClaudeAgentSession implements AgentSession {
this.activeTurnPromise = null;
this.sidechainTracker.clear();
this.input?.end();
this.query?.close();
await this.awaitWithTimeout(this.query?.interrupt?.(), "close query interrupt");
await this.awaitWithTimeout(this.query?.return?.(), "close query return");
this.query = null;
@@ -1877,6 +1878,7 @@ class ClaudeAgentSession implements AgentSession {
if (this.queryRestartNeeded && this.query) {
this.input?.end();
this.query.close();
try {
await this.query.return?.();
} catch {