mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Merge pull request #157330 from microsoft/tyriar/reattach
Improved reconnection logging and throw when attaching to orphan processes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user