diff --git a/packages/vscode/src/opencode.ts b/packages/vscode/src/opencode.ts index c1f60f73..d694abbd 100644 --- a/packages/vscode/src/opencode.ts +++ b/packages/vscode/src/opencode.ts @@ -14,6 +14,17 @@ import { registerManagedProcess, unregisterManagedProcess, reapOrphanedProcesses const t = vscode.l10n.t; const READY_CHECK_TIMEOUT_MS = 30000; + +// Reuse a single output channel across restarts instead of creating (and +// leaking) a new one on every waitForReady call. +let managerOutputChannel: vscode.OutputChannel | null = null; + +function getManagerOutputChannel(): vscode.OutputChannel { + if (!managerOutputChannel) { + managerOutputChannel = vscode.window.createOutputChannel('OpenChamberManager'); + } + return managerOutputChannel; +} const WINDOWS_EXECUTABLE_EXTENSIONS = (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') .split(';') .map((ext) => ext.trim().toLowerCase()) @@ -612,7 +623,6 @@ async function waitForReady( timeoutMs = 15000, authHeaders: Record = {} ): Promise { - const outputChannel = vscode.window.createOutputChannel('OpenChamberManager'); const start = Date.now(); const candidates = getCandidateBaseUrls(serverUrl); let attempts = 0; @@ -640,7 +650,7 @@ async function waitForReady( } clearTimeout(timeout); - outputChannel?.appendLine( + getManagerOutputChannel().appendLine( `Health check to ${url.toString()} returned ${res.status} with body: ${JSON.stringify(body)}` );