Skip to content

Commit 4f8f8cb

Browse files
Abort in-flight session turns before shutdown to release session.db handle
A turn still running when the runtime disposes the session can leave that session's SQLite session.db handle open. Over the in-process transport the runtime shares the test process, so the handle is not reclaimed and the file stays locked on Windows, causing EBUSY/ENOTEMPTY when removing the session-state directory during teardown. Abort each session before disconnect so the turn cancels and releases the handle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f642bd6 commit 4f8f8cb

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

nodejs/src/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,15 @@ 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.
918+
await Promise.allSettled(activeSessions.map((session) => session.abort()));
910919
for (const session of activeSessions) {
911920
const sessionId = session.sessionId;
912921
let lastError: Error | null = null;

0 commit comments

Comments
 (0)