-
Notifications
You must be signed in to change notification settings - Fork 845
Cherry-pick VS Code extension fixes from main to release/13.2 #14846
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from '../utils/AspireTerminalProvider'; | ||
|
|
||
| export async function addCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('add'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('add'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from '../utils/AspireTerminalProvider'; | ||
|
|
||
| export async function deployCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('deploy'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('deploy'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from "../utils/AspireTerminalProvider"; | ||
|
|
||
| export async function initCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('init'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('init'); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from "../utils/AspireTerminalProvider"; | ||
|
|
||
| export async function newCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('new'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('new'); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from '../utils/AspireTerminalProvider'; | ||
|
|
||
| export async function publishCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('publish'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('publish'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AspireTerminalProvider } from '../utils/AspireTerminalProvider'; | ||
|
|
||
| export async function updateCommand(terminalProvider: AspireTerminalProvider) { | ||
| terminalProvider.sendAspireCommandToAspireTerminal('update'); | ||
| await terminalProvider.sendAspireCommandToAspireTerminal('update'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,8 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
| private _trackedDebugAdapters: string[] = []; | ||
| private _rpcClient?: ICliRpcClient; | ||
| private readonly _disposables: vscode.Disposable[] = []; | ||
| private _disposed = false; | ||
| private _userInitiatedStop = false; | ||
|
|
||
| public readonly onDidSendMessage = this._onDidSendMessage.event; | ||
| public readonly debugSessionId: string; | ||
|
|
@@ -93,18 +95,19 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
| if (isDirectory(appHostPath)) { | ||
| this.sendMessageWithEmoji("📁", launchingWithDirectory(appHostPath)); | ||
|
|
||
| this.spawnRunCommand(args, appHostPath, noDebug); | ||
| void this.spawnRunCommand(args, appHostPath, noDebug); | ||
| } | ||
| else { | ||
| this.sendMessageWithEmoji("📂", launchingWithAppHost(appHostPath)); | ||
|
|
||
| const workspaceFolder = path.dirname(appHostPath); | ||
| args.push('--project', appHostPath); | ||
| this.spawnRunCommand(args, workspaceFolder, noDebug); | ||
| void this.spawnRunCommand(args, workspaceFolder, noDebug); | ||
| } | ||
|
Comment on lines
101
to
106
|
||
| } | ||
| else if (message.command === 'disconnect' || message.command === 'terminate') { | ||
| this.sendMessageWithEmoji("🔌", disconnectingFromSession); | ||
| this._userInitiatedStop = true; | ||
| this.dispose(); | ||
|
|
||
| this.sendEvent({ | ||
|
|
@@ -133,7 +136,7 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
| } | ||
| } | ||
|
|
||
| spawnRunCommand(args: string[], workingDirectory: string | undefined, noDebug: boolean) { | ||
| async spawnRunCommand(args: string[], workingDirectory: string | undefined, noDebug: boolean) { | ||
| const disposable = this._rpcServer.onNewConnection((client: ICliRpcClient) => { | ||
| if (client.debugSessionId === this.debugSessionId) { | ||
| this._rpcClient = client; | ||
|
|
@@ -143,7 +146,7 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
|
|
||
| spawnCliProcess( | ||
| this._terminalProvider, | ||
| this._terminalProvider.getAspireCliExecutablePath(), | ||
| await this._terminalProvider.getAspireCliExecutablePath(), | ||
| args, | ||
| { | ||
| stdoutCallback: (data) => { | ||
|
|
@@ -173,7 +176,9 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
|
|
||
| this._disposables.push({ | ||
| dispose: () => { | ||
| this._rpcClient?.stopCli(); | ||
| this._rpcClient?.stopCli().catch((err) => { | ||
| extensionLogOutputChannel.info(`stopCli failed (connection may already be closed): ${err}`); | ||
| }); | ||
| extensionLogOutputChannel.info(`Requested Aspire CLI exit with args: ${args.join(' ')}`); | ||
| } | ||
| }); | ||
|
|
@@ -219,9 +224,15 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
|
|
||
| const disposable = vscode.debug.onDidTerminateDebugSession(async session => { | ||
| if (this._appHostDebugSession && session.id === this._appHostDebugSession.id) { | ||
| // We should also dispose of the parent Aspire debug session whenever the AppHost stops. | ||
| const shouldRestart = !this._userInitiatedStop; | ||
| const config = this.configuration; | ||
| // Always dispose the current Aspire debug session when the AppHost stops. | ||
| this.dispose(); | ||
| disposable.dispose(); | ||
|
|
||
| if (shouldRestart) { | ||
| extensionLogOutputChannel.info('AppHost terminated unexpectedly, restarting Aspire debug session'); | ||
| await vscode.debug.startDebugging(undefined, config); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -281,11 +292,14 @@ export class AspireDebugSession implements vscode.DebugAdapter { | |
| } | ||
|
|
||
| dispose(): void { | ||
| if (this._disposed) { | ||
| return; | ||
| } | ||
| this._disposed = true; | ||
| extensionLogOutputChannel.info('Stopping the Aspire debug session'); | ||
| vscode.debug.stopDebugging(this._session); | ||
| this._disposables.forEach(disposable => disposable.dispose()); | ||
| this._trackedDebugAdapters = []; | ||
| this._rpcClient?.stopCli(); | ||
| } | ||
|
|
||
| private sendResponse(request: any, body: any = {}) { | ||
|
|
||
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.
handleMessage() starts spawnRunCommand() with
voidand no error handling. Since spawnRunCommand is now async (awaiting CLI path resolution), a rejection (e.g., config update failure during resolveCliPath) would become an unhandled promise rejection. Consider wrapping spawnRunCommand in a try/catch internally, or attaching a.catch(...)when calling it to log and surface a user-friendly error.