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:
@@ -1611,6 +1611,7 @@ class ClaudeAgentSession implements AgentSession {
|
|||||||
this.activeTurnPromise = null;
|
this.activeTurnPromise = null;
|
||||||
this.sidechainTracker.clear();
|
this.sidechainTracker.clear();
|
||||||
this.input?.end();
|
this.input?.end();
|
||||||
|
this.query?.close();
|
||||||
await this.awaitWithTimeout(this.query?.interrupt?.(), "close query interrupt");
|
await this.awaitWithTimeout(this.query?.interrupt?.(), "close query interrupt");
|
||||||
await this.awaitWithTimeout(this.query?.return?.(), "close query return");
|
await this.awaitWithTimeout(this.query?.return?.(), "close query return");
|
||||||
this.query = null;
|
this.query = null;
|
||||||
@@ -1877,6 +1878,7 @@ class ClaudeAgentSession implements AgentSession {
|
|||||||
|
|
||||||
if (this.queryRestartNeeded && this.query) {
|
if (this.queryRestartNeeded && this.query) {
|
||||||
this.input?.end();
|
this.input?.end();
|
||||||
|
this.query.close();
|
||||||
try {
|
try {
|
||||||
await this.query.return?.();
|
await this.query.return?.();
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user