Repository navigation
fix: do not end a new session at once when its initiating view closed - #3048
Merged
Merged
Conversation
On macOS CI, setUpClass sometimes times out while it waits for the session to become ready. The test captured the first session that it found, but that session can stop before it is seen as ready, and then LSP starts a new session. Wait for a ready session and capture that session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The view that started a session can close while the server initializes. Then _dequeue_listener_async ended the new session at once, although a pending listener could still use it, and started a second server. For a short time, the stopping session was visible in WindowManager._sessions. This made TextDocumentTestCase.setUpClass flaky on macOS CI. End the session only if no view uses it after a short delay. This is the same idle shutdown that unregister_session_view_async uses. This commit also reverts the test change from the previous commit, because the test change only hid the problem. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rchl
marked this pull request as ready for review
October 1, 2026 21:27
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 the flaky
TextDocumentTestCase.setUpClasstimeouts on macOS CI (for example https://github.com/sublimelsp/LSP/actions/runs/36761225504 and https://github.com/sublimelsp/LSP/actions/runs/36917769576).Cause
A trace from a failing macOS run showed this sequence:
add_config.restart_sessions_asyncregisters all known listeners again, including the listener of the closing view. That view is still valid, so a session starts for it. The new test view waits in the queue._dequeue_listener_asyncadds the session to_sessions, finds that it has no views and ends it at once. The test can find the session in that short time.1 != 0).This is also a real issue outside the tests: when the view that started a session closes during
initialize, LSP starts a second server for nothing.Fix
When a new session has no views, do not end it at once. End it only if no view uses it after a short delay (
Session.end_async_if_unused). This is the same idle shutdown thatunregister_session_view_asyncalready uses. The pending listener then uses the same session.Testing
The branch has temporary commits (macOS-only matrix, 10 attempts, trace prints) and a final cleanup commit that removes them. The net change is in
plugin/core/sessions.pyandplugin/core/windows.pyonly. Squash on merge.π€ Generated with Claude Code