fix: resolve MCP server connection race condition (#5591) #5592
+7
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5591
This PR resolves a critical race condition that was preventing MCP servers from connecting during extension startup. The issue was caused by simultaneous access to
vscode.extensions.all
by both MCP initialization and theme loading processes.Root Cause
The error "Cannot assign to read only property 'all'" occurred when:
getTheme()
function) iterated throughvscode.extensions.all
Changes Made
src/integrations/theme/getTheme.ts
:[...vscode.extensions.all]
to avoid read-only property conflictsextension?.packageJSON?.contributes?.themes?.length > 0
Testing
Verification of Acceptance Criteria
Impact
Files Changed
src/integrations/theme/getTheme.ts
- Fixed race condition in extension iterationThis fix ensures MCP servers can connect reliably during extension startup while maintaining all existing theme loading functionality.
Important
Fixes race condition in
getTheme.ts
by creating a local copy ofvscode.extensions.all
and adding null checks, ensuring reliable MCP server connections during startup.getTheme()
ingetTheme.ts
by creating a local copy ofvscode.extensions.all
.extension
andpackageJSON
to prevent errors during iteration.This description was created by
for 081380f. You can customize this summary. It will automatically update as commits are pushed.