Skip to content

fixed the Python extension failing in the virtual workspace on IInterpreterPathService#24050

Closed
heejaechang wants to merge 1 commit intomicrosoft:mainfrom
heejaechang:fixMock
Closed

fixed the Python extension failing in the virtual workspace on IInterpreterPathService#24050
heejaechang wants to merge 1 commit intomicrosoft:mainfrom
heejaechang:fixMock

Conversation

@heejaechang
Copy link
Copy Markdown

@heejaechang heejaechang commented Sep 4, 2024

Issue was found during testing pylance on virtual workspace.

....

I fixed the Python extension failing in the virtual workspace on IInterpreterPathService

The root cause seems to be that IDisposableRegistry is now considered an array of services (after the Inversify update), and having one of the items with catch/then causes Inversify to think the service is being called with the wrong API (get instead of getAsync), throwing the following exception:

You are attempting to construct '" + key + "' in a synchronous way\n but it has asynchronous dependencies.

Ideally, IDisposableRegistry should be an actual service rather than a type alias of IDisposable[], but that would require too many changes. Instead, I fixed the item that goes into the IDisposable[].

That item (a mock) was considered a Promise because the mock automatically generates any symbol that is accessed. I bypassed then and catch by returning undefined, so it is no longer treated as a Promise.

It would be nice if IDisposableRegistry became a real service at some point so this issue wouldn't occur again.

....

how should I add a test for this change?

…erpreterPathService.

The root cause seems to be that `IDisposableRegistry` is now considered an array of services (after the Inversify update), and having one of the items with catch/then causes `Inversify` to think the service is being called with the wrong API (`get` instead of `getAsync`), throwing the following exception:

> You are attempting to construct '" + key + "' in a synchronous way\n but it has asynchronous dependencies.

Ideally, `IDisposableRegistry` should be an actual service rather than a type alias of `IDisposable[]`, but that would require too many changes. Instead, I fixed the item that goes into the `IDisposable[]`.

That item (a mock) was considered a Promise because the mock automatically generates any symbol that is accessed. I bypassed `then` and `catch` by returning undefined, so it is no longer treated as a Promise.

It would be nice if `IDisposableRegistry` became a real service at some point so this issue wouldn't occur again.
@heejaechang heejaechang changed the title I fixed the Python extension failing in the virtual workspace on IInterpreterPathService fixed the Python extension failing in the virtual workspace on IInterpreterPathService Sep 4, 2024
@karthiknadig
Copy link
Copy Markdown
Member

I think this might address it better: #24051

@heejaechang heejaechang closed this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants