Skip to content

Commit 496818e

Browse files
fix: scope teardown session-abort to the in-process transport only
The abort-before-teardown only exists to release the runtime's SQLite session.db handle over the in-process (FFI) transport, where the runtime shares this process. stdio/tcp runtimes run in a child process we kill on shutdown, which already frees the handle, so don't abort there. Gate on connectionConfig.kind === 'inprocess' and note it's temporary until the runtime cleans up fully on shutdown. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d2c1f6c commit 496818e

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

nodejs/src/client.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -907,17 +907,18 @@ export class CopilotClient {
907907

908908
// Disconnect all active sessions with retry logic
909909
const activeSessions = [...this.sessions.values()];
910-
// Abort any in-flight turn before teardown. A turn still running when
911-
// the runtime disposes the session can leave that session's SQLite
912-
// session.db handle open in the runtime; over the in-process transport
913-
// the runtime shares this process, so the handle is not reclaimed by
914-
// terminating a child and the file stays locked (Windows), preventing
915-
// removal of the session-state directory. Aborting lets the turn cancel
916-
// and release the handle. Best-effort and idempotent: a session with no
917-
// active turn is a no-op. Skip for external servers: we don't own that
918-
// runtime, and aborting would cancel pending work other clients may
919-
// still resume.
920-
if (!this.isExternalServer) {
910+
// TEMPORARY: over the in-process (FFI) transport the runtime shares this
911+
// process, so a turn still running when the runtime disposes the session
912+
// can leave that session's SQLite session.db handle open — it isn't
913+
// reclaimed by terminating a child process, so the file stays locked
914+
// (Windows) and the session-state directory can't be removed. Abort any
915+
// in-flight turn first so it cancels and releases the handle. Best-effort
916+
// and idempotent: a session with no active turn is a no-op. Scoped to
917+
// in-process only: stdio/tcp runtimes run in a child process that we kill
918+
// on shutdown (which frees the handle), and for external servers we don't
919+
// own the runtime and aborting would cancel pending work other clients
920+
// may still resume. Remove once the runtime cleans up fully on shutdown.
921+
if (this.connectionConfig.kind === "inprocess") {
921922
await Promise.allSettled(activeSessions.map((session) => session.abort()));
922923
}
923924
for (const session of activeSessions) {

0 commit comments

Comments
 (0)