fix(dotnet): abort in-flight turns before disposing sessions on in-process shutdown - #1961
Closed
SteveSandersonMS wants to merge 1 commit into
Closed
SteveSandersonMS wants to merge 1 commit into
SteveSandersonMS wants to merge 1 commit into
Conversation
…ocess shutdown Cross-SDK parity with the Node.js fix. Over the in-process (FFI) transport the runtime shares the SDK process, so a turn still running when a session is disposed can leave that session's SQLite session.db handle open. The handle is not reclaimed by terminating a child process (there is none), so on Windows the file stays locked and the session-state temp directory can't be removed. StopAsync() now aborts any in-flight turn before DisposeAsync() for in-process connections, releasing the handle. Scoped to InProcessRuntimeConnection only: stdio/tcp runtimes run in a child process we kill on shutdown, and external servers are shared. Abort+dispose run per-session in a single parallel Task.WhenAll. Re-enables the windows-latest + inprocess leg in dotnet-sdk-tests.yml. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
No, not sufficient. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Cross-SDK parity with the Node.js in-process shutdown fix.
Over the in-process (FFI) transport the runtime shares the SDK process, so a turn still running when a session is disposed can leave that session's SQLite
session.dbhandle open. Because there is no child process to terminate, the handle is never reclaimed — on Windows the file stays locked and the session-state temp directory can't be removed.Changes
CopilotClient.StopAsync()now aborts any in-flight turn (session.AbortAsync()) beforesession.DisposeAsync(), releasing the handle. Aborting a session with no active turn is a no-op.InProcessRuntimeConnectiononly: stdio/tcp runtimes run in a child process we kill on shutdown (which frees the handle), and for external servers we don't own the runtime and aborting would cancel pending work other clients may still resume.Task.WhenAll.TEMPORARY— remove once the runtime cleans up fully on shutdown.windows-latest+inprocessmatrix leg indotnet-sdk-tests.yml(previously excluded pending this fix).Context
Follow-up to the equivalent Node.js SDK fix. See #1934 for the broader in-process transport tracking.