`session.disconnect()` is cooperative; doesn't abort `sendAndWait` or close the transport
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- node.js, typescript
- Ambito
- api, backend-api-design
Direzione di ricerca
Inizia in nodejs/src/session.ts, concentrandoti su disconnect(), abort(), sendAndWait() e sul loro utilizzo di MessageConnection. Traccia la gestione delle richieste in corso e della chiusura del trasporto, quindi chiarisci se la cancellazione debba preservare la validità della sessione o forzarne lo smantellamento; il lavoro è concluso quando il comportamento scelto è esplicito e le chiamate in corso terminano rapidamente con un errore pulito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
session.disconnect() sends session.destroy over RPC and clears local handlers, but does not close the underlying MessageConnection. Any in-flight sendAndWait() continues to await events from the CLI for up to TCP-timeout duration. The method name implies abortive semantics; the behavior is cooperative signaling.
Repro
const client = new CopilotClient();
await client.start();
const session = await client.createSession({ /* ... */ });
// Start a long-running call
const inflight = session.sendAndWait({ prompt: "Write a very long story..." });
// Try to abort after 5 seconds
setTimeout(async () => {
await session.disconnect();
console.log("disconnect() returned");
}, 5000);
// `inflight` does NOT reject after disconnect returns; it continues to
// pend for up to 30–90 minutes (until the CLI's natural completion or
// TCP timeout).
await inflight;
Expected
disconnect() returns → underlying transport closed → in-flight sendAndWait() rejects with a clean SessionAborted (or similar) error → consumer can release resources immediately.
Actual
disconnect() returns immediately but the JSON-RPC transport stays open. The in-flight sendAndWait() is unaffected and continues running until the CLI naturally returns or TCP times out (often 30+ minutes).
Evidence (SDK source)
nodejs/src/session.ts (v0.3.0): disconnect() calls sendRequest("session.destroy", { sessionId }) and clears local eventHandlers. No call to connection.close() or transport-level termination. session.abort() (same file, line ~1073) sends session.abort to cancel the current message at the CLI but also doesn't close the SDK-side transport.
Workaround (consumer-side)
Layer an AbortController on the polling layer plus a "session result ignored" flag so the eventually-resolving sendAndWait doesn't pollute downstream state. ~50–100 LOC of scaffolding that every consumer with reliability requirements has to reinvent.
Suggested fix (pick one)
- Enhance
abort()to also reject in-flightsendAndWaitwith a cleanSessionAbortederror, preserving session validity for new messages. Suits "cancel and retry" consumers. - Add
session.disconnect({ force: true })(orsession.kill()) that closes the underlying JSON-RPC connection immediately. Suits "tear down for good" consumers — the watchdog scenario above. Keep current cooperativedisconnect()behavior as the default.
Related
- #590 — "Long-running prompt suddenly hangs forever with no error or exception" — describes the symptom from the consumer side. The disconnect-doesn't-abort behavior is one mechanism that contributes to this symptom: even when the consumer notices the hang and tries to recover,
disconnect()doesn't free the in-flight call cleanly.
Environment
- SDK: @github/copilot-sdk@0.3.0
- CLI: @github/copilot@1.0.45
- Node: 22 LTS
- OS: Windows 11 (primary), macOS 14 (secondary)
- Model: claude-sonnet-4-6 (CLI default routing)
- Lingua principale
- Java
- Stelle
- 10.5k
- Fork
- 1.5k
- Merge medio
- 1g 9h
- PR unite (30g)
- 131
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/copilot-sdk
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/copilot-sdk#2709 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
github/copilot-sdk#2673 ·
-
bug testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
github/copilot-sdk#2628 ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/copilot-sdk#2627 · 1 commento ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
github/copilot-sdk#2493 ·
Tutte le issue di github/copilot-sdk
Issue simili
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/flink-agents#1152 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
objectionary/eo-graphs#75 ·