Skip to content

Conversation

@kinto0
Copy link
Contributor

@kinto0 kinto0 commented Nov 25, 2025

Summary:
When switching Python interpreters via workspace/didChangeConfiguration, the LSP
would sometimes show stale diagnostics because of a race condition in how config
invalidation and diagnostic publishing interacted.

The issue was that invalidate_config_and_validate_in_memory() would:

  1. Invalidate configs and mark modules as dirty
  2. Commit the transaction with updated configs
  3. Send RecheckFinished event to trigger diagnostic publishing

However, the RecheckFinished event handler could run and publish diagnostics
before modules had actually re-run with the new config, resulting in diagnostics
that still showed errors from the old interpreter's site-packages.

The fix is to publish diagnostics immediately after committing the config
invalidation transaction, using a fresh transaction that reflects the newly
committed state. This ensures diagnostics always use the updated configs.

Additionally, extracted the diagnostic publishing logic into a reusable
publish_diagnostics_for_handles() method to avoid code duplication.

This likely helps with #1667

Differential Revision: D87848835

Summary:
interpreter fails to update type errors when changing from a bad one to a good one

reported here facebook#1632

Differential Revision: D87664939
Summary:
When switching Python interpreters via workspace/didChangeConfiguration, the LSP
would sometimes show stale diagnostics because of a race condition in how config
invalidation and diagnostic publishing interacted.

The issue was that invalidate_config_and_validate_in_memory() would:
1. Invalidate configs and mark modules as dirty
2. Commit the transaction with updated configs
3. Send RecheckFinished event to trigger diagnostic publishing

However, the RecheckFinished event handler could run and publish diagnostics
before modules had actually re-run with the new config, resulting in diagnostics
that still showed errors from the old interpreter's site-packages.

The fix is to publish diagnostics immediately after committing the config
invalidation transaction, using a fresh transaction that reflects the newly
committed state. This ensures diagnostics always use the updated configs.

Additionally, extracted the diagnostic publishing logic into a reusable
publish_diagnostics_for_handles() method to avoid code duplication.

This likely helps with facebook#1667

Differential Revision: D87848835
@meta-cla meta-cla bot added the cla signed label Nov 25, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 25, 2025

@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87848835.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant