Merge pull request #157330 from microsoft/tyriar/reattach

Improved reconnection logging and throw when attaching to orphan processes
This commit is contained in:
Daniel Imms
2022-08-06 08:01:03 -07:00
committed by GitHub
2 changed files with 11 additions and 11 deletions
+9 -9
View File
@@ -213,9 +213,9 @@ export class PtyService extends Disposable implements IPtyService {
async attachToProcess(id: number): Promise<void> {
try {
await this._throwIfNoPty(id).attach();
this._logService.trace(`Persistent process reconnection "${id}"`);
this._logService.info(`Persistent process reconnection "${id}"`);
} catch (e) {
this._logService.trace(`Persistent process reconnection "${id}" failed`, e.message);
this._logService.warn(`Persistent process reconnection "${id}" failed`, e.message);
throw e;
}
}
@@ -341,7 +341,7 @@ export class PtyService extends Disposable implements IPtyService {
try {
return this._revivedPtyIdMap.get(id)?.newId;
} catch (e) {
this._logService.trace(`Couldn't find terminal ID ${id}`, e.message);
this._logService.warn(`Couldn't find terminal ID ${id}`, e.message);
}
return undefined;
}
@@ -384,7 +384,7 @@ export class PtyService extends Disposable implements IPtyService {
relativeSize: t.relativeSize
};
} catch (e) {
this._logService.trace(`Couldn't get layout info, a terminal was probably disconnected`, e.message);
this._logService.warn(`Couldn't get layout info, a terminal was probably disconnected`, e.message);
// this will be filtered out and not reconnected
return {
terminal: null,
@@ -582,12 +582,12 @@ export class PersistentTerminalProcess extends Disposable {
async attach(): Promise<void> {
this._logService.trace('persistentTerminalProcess#attach', this._persistentProcessId);
// Something wrong happened if the disconnect runner is not canceled, this likely means
// multiple windows attempted to attach.
if (!await this._isOrphaned()) {
throw new Error(`Cannot attach to persistent process "${this._persistentProcessId}", it is already adopted`);
}
if (!this._disconnectRunner1.isScheduled() && !this._disconnectRunner2.isScheduled()) {
// Something wrong happened if the disconnect runner is not canceled, this likely means
// multiple windows attempted to attach.
if (!await this._isOrphaned()) {
throw new Error(`Cannot attach to persistent process "${this._persistentProcessId}", it is already adopted`);
}
this._logService.warn(`Persistent process "${this._persistentProcessId}": Process had no disconnect runners but was an orphan`);
}
this._disconnectRunner1.cancel();
@@ -163,7 +163,7 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
this._ptys.set(id, pty);
return pty;
} catch (e) {
this._logService.trace(`Couldn't attach to process ${e.message}`);
this._logService.warn(`Couldn't attach to process ${e.message}`);
}
return undefined;
}
@@ -173,7 +173,7 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
const newId = await this._localPtyService.getRevivedPtyNewId(id) ?? id;
return await this.attachToProcess(newId);
} catch (e) {
this._logService.trace(`Couldn't attach to process ${e.message}`);
this._logService.warn(`Couldn't attach to process ${e.message}`);
}
return undefined;
}