Bail out of create process if it's been disposed
This is likely the cause of several terminal test issues we've been seeing, especially on remote. When process creation becomes async, the process seems to hang around if the terminal was disposed during the process creation. Another thing to consider if env var relaunches messing with tests.
This commit is contained in:
parent
258ee03bfb
commit
755fae50ab
|
@ -103,6 +103,11 @@ import { assertNoRpc } from '../utils';
|
|||
}));
|
||||
terminal.dispose();
|
||||
});
|
||||
|
||||
// Wait for end of task process
|
||||
// await new Promise<void>(r => {
|
||||
// disposables.push(tasks.onDidEndTaskProcess(() => r));
|
||||
// });
|
||||
});
|
||||
|
||||
test('sync CustomExecution task should flush all data on close', async () => {
|
||||
|
|
|
@ -176,8 +176,6 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
|
|||
this._onProcessOverrideDimensions.fire(e);
|
||||
}
|
||||
handleResolvedShellLaunchConfig(e: IShellLaunchConfig) {
|
||||
// TODO: Revive shell launch config
|
||||
console.log('handleResolvedShellLaunchConfig', e);
|
||||
this._onProcessResolvedShellLaunchConfig.fire(e);
|
||||
}
|
||||
|
||||
|
@ -200,7 +198,6 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
|
|||
}
|
||||
|
||||
handleOrphanQuestion() {
|
||||
console.log('handle orphan question', this._id);
|
||||
this._remoteTerminalChannel.orphanQuestionReply(this._id);
|
||||
}
|
||||
|
||||
|
@ -212,6 +209,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Revive?
|
||||
// function reviveIShellLaunchConfig(dto: IShellLaunchConfigDto): IShellLaunchConfig {
|
||||
// return {
|
||||
// name: dto.name,
|
||||
|
|
|
@ -971,6 +971,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
}
|
||||
|
||||
private _createProcess(): void {
|
||||
if (this._isDisposed) {
|
||||
return;
|
||||
}
|
||||
this._processManager.createProcess(this._shellLaunchConfig, this._cols, this._rows, this._accessibilityService.isScreenReaderOptimized()).then(error => {
|
||||
if (error) {
|
||||
this._onProcessExit(error);
|
||||
|
|
|
@ -59,6 +59,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
|||
public userHome: string | undefined;
|
||||
public isDisconnected: boolean = false;
|
||||
|
||||
private _isDisposed: boolean = false;
|
||||
private _process: ITerminalChildProcess | null = null;
|
||||
private _processType: ProcessType = ProcessType.Process;
|
||||
private _preLaunchInputQueue: string[] = [];
|
||||
|
@ -137,6 +138,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
|||
}
|
||||
|
||||
public dispose(immediate: boolean = false): void {
|
||||
this._isDisposed = true;
|
||||
if (this._process) {
|
||||
// If the process was still connected this dispose came from
|
||||
// within VS Code, not the process, so mark the process as
|
||||
|
@ -207,6 +209,9 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
|||
this._process = await this._remoteTerminalService.createProcess(shellLaunchConfig, activeWorkspaceRootUri, cols, rows, shouldPersist, this._configHelper);
|
||||
}
|
||||
this._setupPtyHostListeners(this._remoteTerminalService);
|
||||
if (!this._isDisposed) {
|
||||
this._setupPtyHostListeners(this._remoteTerminalService);
|
||||
}
|
||||
} else {
|
||||
if (!this._localTerminalService) {
|
||||
this._logService.trace(`Tried to launch a local terminal which is not supported in this window`);
|
||||
|
@ -223,10 +228,17 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
|||
} else {
|
||||
this._process = await this._launchLocalProcess(this._localTerminalService, shellLaunchConfig, cols, rows, this.userHome, isScreenReaderModeEnabled);
|
||||
}
|
||||
this._setupPtyHostListeners(this._localTerminalService);
|
||||
if (!this._isDisposed) {
|
||||
this._setupPtyHostListeners(this._localTerminalService);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._isDisposed) {
|
||||
this._process.shutdown(false);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
this.processState = ProcessState.LAUNCHING;
|
||||
|
||||
this._process.onProcessData(ev => {
|
||||
|
|
Loading…
Reference in a new issue