Repository navigation
Wait for active interpreter resolution before reporting invalid interpreter - #26318
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new test fails on Windows because it expects one interpreter lookup, but _manualDiagnose() triggers two, so the expected call count must be platform-dependent.
1 open issue
What changed in this PR
This PR addresses #26317 by making interpreter diagnostics wait for resolution before reporting an invalid interpreter, while preserving the 100 ms timeout for other callers.
Changes:
- Adds an opt-in
waitForResolutionoption to active interpreter lookup. - Enables waiting in invalid-interpreter and default-shell diagnostics.
- Updates mocks and adds regression tests for delayed resolution.
| File | Description |
|---|---|
src/test/interpreters/interpreterService.unit.test.ts |
Adds coverage for slow cold-start resolution. |
src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts |
Updates mocks and verifies diagnostics request resolution waiting. |
src/client/interpreter/interpreterService.ts |
Bypasses the timeout when waiting is requested. |
src/client/interpreter/contracts.ts |
Declares the optional waitForResolution flag. |
src/client/application/diagnostics/checks/pythonInterpreter.ts |
Waits for resolution before evaluating interpreter diagnostics. |
Review effort: Balanced
| ), | ||
| ) | ||
| .returns(() => Promise.resolve(({ path: 'interpreterpath' } as unknown) as PythonEnvironment)) | ||
| .verifiable(typemoq.Times.once()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Fixes #26317.
Root Cause
InterpreterService.getActiveInterpreterracesresolveActiveInterpreteragainstGET_ACTIVE_INTERPRETER_TIMEOUT_MS(100ms) so callers like language server startup are not blocked. On a cold start (no cached or persisted interpreter yet), if interpreter resolution takes longer than 100ms (e.g., when activated via another extension's API while the Python Environments extension is still resolving),getActiveInterpreterreturnsundefinedwhile resolution is still in flight.InvalidPythonInterpreterService._manualDiagnosecalledgetActiveInterpreter(resource)directly and immediately surfacedInvalidPythonInterpreterDiagnostic("An Invalid Python interpreter is selected...") when it receivedundefined.Changes
waitForResolution?: booleantoGetActiveInterpreterOptionsinsrc/client/interpreter/contracts.ts.InterpreterService.getActiveInterpreterinsrc/client/interpreter/interpreterService.tsto awaitresolutiondirectly whenoptions?.waitForResolutionistrue, preserving the 100ms timeout for all other callers.InvalidPythonInterpreterService._manualDiagnoseanddiagnoseDefaultShellinsrc/client/application/diagnostics/checks/pythonInterpreter.tsto pass{ waitForResolution: true }.pythonInterpreter.unit.test.tsandinterpreterService.unit.test.ts.Verification
npx tsc -p ./: 0 errorsnpx mocha --require out/test/unittests.js --ui tdd out/test/application/diagnostics/checks/pythonInterpreter.unit.test.js out/test/interpreters/interpreterService.unit.test.js: 34 passing, 3 pending (Windows-only)npx eslinton all 5 modified files: 0 errors