fix(vscode): reuse manager output channel across restarts

This commit is contained in:
tttpob
2026-08-04 16:08:33 +08:00
parent f710b49854
commit 4b6cf1d40a
+12 -2
View File
@@ -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<string, string> = {}
): Promise<ReadyResult> {
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)}`
);