From 897a11ac3640109c6ff7114e9e4df1121b1a3e56 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 18 Jul 2025 17:31:49 +0000 Subject: [PATCH] fix: resolve MCP server connection race condition in getTheme.ts - Create local copy of vscode.extensions.all to avoid read-only property conflicts - Add defensive null checking for extension and packageJSON - Resolves race condition between MCP initialization and theme loading - Reapplies fix from automatically closed PR #5592 Fixes #5591 --- src/integrations/theme/getTheme.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/integrations/theme/getTheme.ts b/src/integrations/theme/getTheme.ts index 20171cc304..7270f284ac 100644 --- a/src/integrations/theme/getTheme.ts +++ b/src/integrations/theme/getTheme.ts @@ -37,12 +37,16 @@ export async function getTheme() { const colorTheme = vscode.workspace.getConfiguration("workbench").get("colorTheme") || "Default Dark Modern" try { - for (let i = vscode.extensions.all.length - 1; i >= 0; i--) { + // Create a local copy of the extensions array to avoid potential conflicts with the read-only property + const extensions = [...vscode.extensions.all] + + for (let i = extensions.length - 1; i >= 0; i--) { if (currentTheme) { break } - const extension = vscode.extensions.all[i] - if (extension.packageJSON?.contributes?.themes?.length > 0) { + const extension = extensions[i] + // Add null check for extension and packageJSON + if (extension?.packageJSON?.contributes?.themes?.length > 0) { for (const theme of extension.packageJSON.contributes.themes) { if (theme.label === colorTheme) { const themePath = path.join(extension.extensionPath, theme.path)