Repository navigation
Unblock Copilot session refresh after SDK shutdown - #328391
Merged
Ulugbek Abdullaev (ulugbekna) merged 1 commit intoAug 2, 2026
Merged
Ulugbek Abdullaev (ulugbekna) merged 1 commit into
Ulugbek Abdullaev (ulugbekna) merged 1 commit into
Conversation
Treat the SDK session.shutdown event as authoritative teardown completion when the disconnect RPC response remains pending, while memoizing disconnect to avoid duplicate destroy requests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 6141965e-4144-4a12-b7c0-2851f64a84cf
Ulugbek Abdullaev (ulugbekna)
requested review from
Connor Peet (connor4312) and
Copilot
July 31, 2026 11:41
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents Copilot session refreshes from blocking when SDK shutdown precedes the disconnect RPC response.
Changes:
- Completes disconnect on either RPC response or
session.shutdown. - Memoizes disconnect requests to prevent duplicate destruction.
- Adds regression coverage for shutdown-before-response ordering.
Show a summary per file
| File | Description |
|---|---|
copilotSessionWrapper.ts |
Adds lifecycle-aware, memoized disconnect handling. |
copilotAgentSession.ts |
Routes session destruction through the wrapper. |
copilotAgentSession.test.ts |
Tests early shutdown and single disconnect invocation. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
Connor Peet (connor4312)
approved these changes
Jul 31, 2026
Ulugbek Abdullaev (ulugbekna)
enabled auto-merge (squash)
August 2, 2026 20:07
auto-merge was automatically disabled
August 2, 2026 20:07
Pull request was closed
Ulugbek Abdullaev (ulugbekna)
enabled auto-merge (squash)
August 2, 2026 20:07
Contributor
Ulugbek Abdullaev (ulugbekna)
deleted the
ulugbekna/ulugbekna-investigate-stuck-session
branch
August 2, 2026 20:24
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #327125 and #327126.
PR #327126 correctly made configuration refresh wait for the previous Copilot SDK session to tear down before resuming the same session ID. In this incident, the runtime emitted
session.shutdownand completed destruction, but thedisconnect()RPC promise remained pending while the SDK process drained a large persisted-event/export backlog.CopilotAgent._sendMessageheld the per-session sequencer while awaiting that promise. Cancellation updated protocol state, but provider abort, idle release, and subsequent sends all queued behind the same blocked teardown. A later turn therefore reachedchat/turnStartedbut never reachedsendMessage, leaving the Agents window on Working… indefinitely.This change makes
CopilotSessionWrappertreat either the disconnect response or the SDK's authoritativesession.shutdownevent as teardown completion. The disconnect request is memoized so later wrapper disposal reuses it instead of sending a duplicate destroy request.CopilotAgentSession.destroySession()now goes through that lifecycle-aware wrapper path.Testing:
CopilotAgentSessionshutdown-before-response regression testnpm run typecheck-clientnpm run valid-layers-checklogs
cc Connor Peet (@connor4312)