Skip to content

Pylance startup blocked on environment enumeration (slow first-run / refresh) #26020

Open

Description

@rchiodo

Problem

On first run (and during any full environment refresh), Pylance can take a very long time to start — in local testing the language server initialize was delayed by ~100+ seconds. The root cause is that startup blocks on environment work that doesn't need to gate the server:

  • getActiveInterpreter() waits on the in-progress environment enumeration/refresh (which can take tens of seconds, especially with conda and many envs), so the Python extension can't hand Pylance an interpreter quickly.
  • Activation awaits interpreter auto-selection rather than letting it complete in the background.
  • Conda deep probes (registry scan / conda info --json) run on the startup path even when the environments extension already owns discovery.

Desired behavior

Startup should be fast even on first run. getActiveInterpreter() should return within ~100ms — serving the last-known/persisted interpreter when discovery is slow — and the real value should resolve in the background and update Pylance via the normal change notification (it's acceptable that the active interpreter may change after a full refresh).

Notes

The fix spans three repositories:

  • microsoft/vscode-python (this repo) — non-blocking interpreter resolution + activation.
  • microsoft/vscode-python-environments — return last-known environment when getEnvironment times out.
  • the Pylance server — don't block initialize on a recursive workspace-folder walk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions