-
Notifications
You must be signed in to change notification settings - Fork 39.7k
sessions: add developer command to kill SSH remote agent host #312193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -590,6 +590,22 @@ export class SSHRemoteAgentHostMainService extends Disposable implements ISSHRem | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async killRemoteAgentHost(host: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const [key, conn] of this._connections) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (key === host || conn.connectionId === host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const exec = bindSshExec(conn.sshClient); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await cleanupRemoteAgentHost(exec, this._logService, this._quality); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._logService.warn(`${LOG_PREFIX} Error killing remote agent host for ${key}: ${err}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conn.dispose(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._logService.warn(`${LOG_PREFIX} killRemoteAgentHost: no active SSH connection found for ${host}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+601
to
+606
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | |
| conn.dispose(); | |
| return; | |
| } | |
| } | |
| this._logService.warn(`${LOG_PREFIX} killRemoteAgentHost: no active SSH connection found for ${host}`); | |
| throw err; | |
| } finally { | |
| conn.dispose(); | |
| } | |
| return; | |
| } | |
| } | |
| const message = localize('sshRemoteAgentHost.killRemoteAgentHost.noActiveConnection', "No active SSH connection found for {0}.", host); | |
| this._logService.warn(`${LOG_PREFIX} killRemoteAgentHost: ${message}`); | |
| throw new Error(message); |
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior in killRemoteAgentHost isn't covered by the existing SSHRemoteAgentHostMainService unit tests. Adding a test that (1) connects, (2) calls killRemoteAgentHost, and (3) asserts cleanup commands ran and the connection was disposed (and that errors/not-found cases surface to callers) would help prevent regressions in this developer escape hatch.
| } | |
| conn.dispose(); | |
| return; | |
| } | |
| } | |
| this._logService.warn(`${LOG_PREFIX} killRemoteAgentHost: no active SSH connection found for ${host}`); | |
| throw err; | |
| } finally { | |
| conn.dispose(); | |
| } | |
| return; | |
| } | |
| } | |
| const error = new Error(`${LOG_PREFIX} killRemoteAgentHost: no active SSH connection found for ${host}`); | |
| this._logService.warn(error.message); | |
| throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warn log interpolates the raw caught value (
${err}), which can produce unhelpful output like[object Object]and may omit stack traces. Use the same pattern as elsewhere in this file (e.g.,err instanceof Error ? err.message : String(err)) or a shared helper liketoErrorMessageso logs are actionable.