From 49dfe32df2da4db0b43eaf9a2668da5a8133122c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 5 Aug 2022 13:55:26 -0700 Subject: [PATCH 1/2] Change log level for reconnect related logs Part of #133542 --- src/vs/platform/terminal/node/ptyService.ts | 8 ++++---- .../terminal/electron-sandbox/localTerminalBackend.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 615de9d6b5a..048cf2d12fb 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -213,9 +213,9 @@ export class PtyService extends Disposable implements IPtyService { async attachToProcess(id: number): Promise { 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, diff --git a/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts b/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts index d61acd4c4a4..410cb5de5ae 100644 --- a/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts +++ b/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts @@ -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; } From b134ea9ec2b3dbbcc8d56c93c93fec1932432496 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 5 Aug 2022 14:01:05 -0700 Subject: [PATCH 2/2] Always throw when attaching to orphan processes Part of #133542 --- src/vs/platform/terminal/node/ptyService.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 048cf2d12fb..4c81a3d1f30 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -582,12 +582,12 @@ export class PersistentTerminalProcess extends Disposable { async attach(): Promise { 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();