Repository navigation
test: open no editor in the socket stop test, whose connect could start the language server again after the stop - #2064
Conversation
…rt the language server again after the stop The editor of a file connects it to its language servers once indexing is done. On a slow machine, as a macOS runner, that can be after the stop of the test, which then sees the language server start again, on a port on which nothing listens anymore, as an error of the stop.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2064 +/- ##
==========================================
+ Coverage 49.49% 49.88% +0.39%
==========================================
Files 813 813
Lines 33345 33396 +51
Branches 6854 5207 -1647
==========================================
+ Hits 16503 16660 +157
+ Misses 14266 14148 -118
- Partials 2576 2588 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
…ahead of its shutdown (#2099) ## What `SelectedEditorConnectionTest.testATabThatClosesWhileItsSelectionWaitsForTheServerLeavesTheFileDisconnected` fails now and then with "the closed file must end disconnected": - on 2025.3 on 2026-11-19; - on macOS in [run 45039702394](https://github.com/redhat-developer/lsp4ij/actions/runs/45039702394) of #2096 on 2026-11-22. The server reads the file's didOpen and never its didClose, even after 10 s. #2019 had replaced a 2 s wait with 10 s waits, but the test kept failing, as no wait fixes it: it's a race in the stop of a language server, older than #2076 and #2096. ## Cause The file is the only document of its language server: 1. When its tab's connection is released, the file is disconnected, and its didClose is queued on the dispatcher. 2. The disconnection then stops the server: at once in tests, after `lastDocumentDisconnectedTimeout` otherwise. 3. The stop sent `shutdown` and `exit` from a pooled thread without waiting for the dispatcher, then closed the connection. When the dispatcher was a few milliseconds late, the didClose went out after the shutdown, which LSP forbids, and after the connection had closed, so the server never read it. A trace of a failing run under load showed it: shutdown sent, shutdown and exit read, connection closed, and only then the didClose dispatched. ## Change Before it sends `shutdown`, the stop of `LanguageServerWrapper` now waits until the dispatcher has handed the notifications queued before the stop to the message writer. So a server is told of the close of its last document before it is told to shut down. - It waits for a second at most, as it already does for the message writer before it closes the connection. After that, the stop goes on as before. - It doesn't wait when the project closes, which stops the server at once, as before. - A stop cancels the initialization of its server, so notifications held back until the server is initialized don't keep it waiting. The failure message of the test now lists the didOpen and didClose notifications of the file that the server read. ## Test - `testTheServerReadsTheDidCloseOfItsLastFileBeforeItStops` holds the dispatcher while the last tab of the server closes, and frees it 200 ms later. It fails without the change and passes with it. - Before the change, the flaky test failed once in 451 runs under CPU load. After it, the flaky test and the new test passed 400 times each under load, 100 of them on 2025.3, with no failure. - 22 related test classes, such as the document move, the stop and the notification order tests, passed 5 times (1,100 tests). - The full suite passed: 1,845 tests, 0 failures, 7 skipped. - It also fixes `LanguageServerInstancesTest.testAMovedFileWhoseEditorClosesAsItIsAskedForAgainIsNotConnected`, which failed on `main` at 30cb393 (2026-11-18, 2026.3) and on a fork run of #2082 (2026-11-22, 2025.3), each after its full 10 s wait. It's the same race: the test's disconnection of the last document queues the `didClose` and stops the server, whose `shutdown` went out first. With the dispatcher held 200 ms before the `didClose`, that test fails 5 of 5 times without this change, and passes 5 of 5 times with it. ## Not changed `SocketLanguageServerTest.testAStopSendsTheExitNotificationBeforeItClosesTheConnection` also failed on macOS 3 times, all before #2064. It's a different cause, and not a lost `exit`: in each failure `exit` arrived, and then the editor that the test opened connected again after the stop and started the server again. #2064 fixed the test, and it hasn't failed in the 51 runs since.
…rflowed, and retry a refused download for a minute (#2175) ## What Main's last CI run, for 436b029, failed on Windows before any test ran: ``` Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugins-bom/2.3.21/kotlin-gradle-plugins-bom-2.3.21.pom'. > Received status code 429 from server: Too Many Requests ``` The job had no cache to start from: setup-gradle said "Gradle User Home cache not found. Will initialize empty.", so it downloaded every dependency again. **Why there was no cache:** the repository's Actions cache holds 12.2 GB, over GitHub's 10 GB per repository. Every entry in it was saved in the 20 minutes before this PR, all on main. The biggest are `gradle-transforms` entries of 3.9, 3.3 and 0.9 GB. They are the IDEs that the IntelliJ Platform Gradle plugin extracts as Gradle artifact transforms, one per job and platform version. Each push to main saves them again for the 5 test jobs, the plugin build and the verifier. GitHub then evicts the oldest entries, the other jobs' downloads among them, and the next run of those jobs fetches everything from Maven Central and JetBrains again. ## Change - **The cache:** every `setup-gradle` step leaves `caches/transforms-4` and `caches/*/transforms` out of the Actions cache, with `gradle-home-cache-excludes`. setup-gradle deletes them before it saves. These are ci.yml, buildZip.yml, IJ.yml, IJ-latest.yml (3 steps), nightly.yml and release.yml. - The downloads themselves stay cached (`gradle-dependencies`, now 1.3 to 2 GB an entry), so the entries fit in 10 GB, and Gradle extracts an IDE again from its cached download without a network access. - Locally the IDEs are in `caches/9.9.2/transforms/*/transformed/extracted`. - **Retries:** Gradle 9.9.2 already retries a download refused with a server error or a 429 (`NetworkingIssueVerifier`), but only 3 times, 1 and 2 seconds apart. `gradle.properties` raises that to 6 times, 2, 4, 8, 16 and 32 seconds apart, with `systemProp.org.gradle.internal.network.retry.max.attempts` and `.initial.backOff`, which `NetworkOperationBackOffAndRetry` reads. A local build prints them back as 6 and 2000 from an init script. ## The other CI failures this week I went through the 22 failed "Java CI with Gradle" runs since 2026-11-17: - **6 were a real break**, fixed by #2138: `InstallerTaskRegistryInitializeTest` failed on every job after #2102. - **Most of the rest were flaky tests, since fixed:** - `LanguageServerManagerInstancesTest` by #2120; - `CancelRequestAfterShutdownTest` by #2162; - `SocketLanguageServerTest` by #2064; - `SelectedEditorConnectionTest` and `FileDocumentMoveTest` by the fixes of #2099 and #2095. - **Seen once and not fixed:** `WatchedFilesTest` (Windows, 2026-11-22) and `LanguageServerInstancesTest` (2026.3, 2026-11-18). - **Since 2026-11-23 14:00 UTC:** 36 runs passed, and the only failure was this 429. ## Check A pull request reads the cache but doesn't write it, so this PR's own CI can't show the saving. After the merge, the next run on main should leave the repository's cache under 10 GB, and the run after it should restore each job's entry. I'll check both.
SocketLanguageServerTest.testAStopSendsTheExitNotificationBeforeItClosesTheConnectionfailed once on the macOS runner of main, at 221e8bf (run):The language server started again during the stop. The test opened
main.sockin an editor (configureByText), and the editor connects its file to its language servers once indexing is done (ConnectDocumentToLanguageServerSetupParticipant.selectionChanged), unless the file is connected already. On a slow machine, that connection can come after the stop has disconnected the file: it then starts the language server again, on a port on which nothing listens anymore, and the test sees the failed start as an error of the stop.testALanguageServerOverASocketAnswersRequestsAndStopsWhenItClosesTheConnectionalready notes that the editor can start the language server again, and doesn't check for errors.The test now creates the file without an editor (
addFileToProject), so nothing connects it after the stop. It doesn't need an editor: it asks for the language servers of the file itself.Test: with a delay of 300ms before the connection of the editor, and a wait of 500ms before the check of the errors, the test fails as on the runner with an editor, and passes without one. The server tests pass (111 tests, 4 Windows-only tests skipped).