From 6601c31c6b5abe060be207907bd3bdcc6f13c418 Mon Sep 17 00:00:00 2001 From: "vs-code-engineering[bot]" <122617954+vs-code-engineering[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 15:16:02 +0000 Subject: [PATCH 1/2] fix: guard setDimensions against disposed ptyProcessReady (fixes #315282) When a terminal process manager is disposed, ptyProcessReady is set to undefined. If setDimensions is called after disposal (e.g., during a resize triggered by a configuration change event that fires during the dispose sequence), calling .then() on undefined throws a TypeError. Add a guard clause to return early when ptyProcessReady is undefined, preventing the crash without masking the error from telemetry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../contrib/terminal/browser/terminalProcessManager.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index 274c4b481e5b9..0c7cec8eca3c4 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -605,6 +605,9 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce return; } + if (!this.ptyProcessReady) { + return Promise.resolve(); + } return this.ptyProcessReady.then(() => this._resize(cols, rows, pixelWidth, pixelHeight)); } From 7871d48508646356a4939c9b02d48220525c59cd Mon Sep 17 00:00:00 2001 From: "vs-code-engineering[bot]" <122617954+vs-code-engineering[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 20:33:02 +0000 Subject: [PATCH 2/2] fix: dispose resize debouncer before process manager to prevent race Dispose _resizeDebouncer before _processManager.dispose() so that no resize callbacks can fire after ptyProcessReady has been nulled. This addresses the root cause (disposal ordering) rather than just guarding against the symptom, as suggested by @bryanchen-d. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../workbench/contrib/terminal/browser/terminalInstance.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 588c01f8628d2..b7c26c253a76d 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1330,6 +1330,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._exitReason = reason ?? TerminalExitReason.Unknown; } + // Dispose the resize debouncer before the process manager so that no + // resize callbacks can fire after ptyProcessReady has been nulled. + this._resizeDebouncer?.dispose(); + this._resizeDebouncer = undefined; + this._processManager.dispose(); // Process manager dispose/shutdown doesn't fire process exit, trigger with undefined if it // hasn't happened yet