Skip to content

test: the language server asks for its configuration over the connection that it shuts down - #2162

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/shutdown-answer-test-race
Nov 23, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/shutdown-answer-test-race

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

What

CancelRequestAfterShutdownTest.testTheAnswerToARequestOfTheLanguageServerIsSentOnceTheShutdownIsSent, which came with #2151, failed once on CI, on macOS 2024.2 (run 45231743923, in #2160):

The language server must read the answer to its request, and exit, after shutdown expected:<[shutdown, ResponseMessage, exit]> but was:<[shutdown, exit]>

It's a bug in the test, not in LSP4IJ or #2151: LSP4IJ did answer the request, but over another connection.

Cause

  • A restart: the test stops the language server while its editor is open. A stop that doesn't disable the language server lets a feature of the editor start it again, over a second connection (start() with the status stopping). The code vision does that when its first lookup of the language servers comes after the stop.

  • The wrong client: the mock language server then has two clients. The test sent workspace/configuration through the last of getRemoteProxies(), which was the new connection's, and that connection answered it. The connection that the test stops, and whose reads it checks, read only shutdown and exit.

  • Reproduced: under CPU load on macOS, with probes, main failed 2 of 2,100 runs. Each time, the second connection read the answer:

    [[initialize, initialized, didOpen, diagnostic, shutdown, exit], [initialize, ResponseMessage, initialized, didOpen, diagnostic, codeLens, $/cancelRequest]]
    

    With a 20 ms delay before the code vision's lookup of the language servers, 7 of 100 runs fail. Asking for the file's language servers right after the shutdown is read fails 20 of 20.

Change

  • The test's connection keeps the client that it gives the language server.
  • The test sends the request through the client of the connection that it stops.
  • The test checks that the request ends with an answer: isDone() is also true for a request that couldn't be sent.

Test

  • With the fix: 0 of 20 runs fail with the forced restart, and 0 of 100 with the delayed code vision (55 of them with two clients when the request was sent).
  • CancelRequestAfterShutdownTest: 8 tests, 0 failures, on IC 2024.2, IC 2025.3 and IU 2026.3.
  • Full suite on IC 2024.2: 2,134 tests, 0 failures, 0 errors, 7 skipped, as before.

…ion that it shuts down

CancelRequestAfterShutdownTest.testTheAnswerToARequestOfTheLanguageServerIsSentOnceTheShutdownIsSent
failed once on macOS 2024.2 (run 45231743923, PR redhat-developer#2160):

    expected:<[shutdown, ResponseMessage, exit]> but was:<[shutdown, exit]>

LSP4IJ answered the request, over another connection. The test stops the language server while its
editor is open. A feature of the editor that asks for the language server after the stop, as the code
vision does when its first lookup comes late, starts it again over a second connection, as a stop that
doesn't disable the language server allows. The mock language server then has two clients, and the test
sent workspace/configuration through the last one, the new connection's, which answered it. The
connection that the test stops, and whose reads it checks, read only shutdown and exit.

The connection now keeps the client that it gives the language server, and the test sends the request
through the client of the connection that it stops. It also checks that the request ends with an answer,
as isDone() is also true for a request that could not be sent.
@lagergren lagergren added this to the 0.30.2 milestone Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved coverage for configuration requests sent over a connection during server shutdown.
    • The test now verifies that the request completes without an exceptional result and uses the same client connection throughout. This strengthens validation of shutdown-related request handling without changing application behavior.

The shutdown-response test now sends the configuration request through the client associated with the connection being shut down. The connection provider stores and exposes that client, and the test checks that the request completes without an exception.

Changes: Shutdown response test

Layer / File(s) Summary
Connection client and shutdown request
src/test/java/com/redhat/devtools/lsp4ij/CancelRequestAfterShutdownTest.java
The connection provider stores and exposes its remote client. The shutdown-response test uses that client for the configuration request and checks that it completes without an exception.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · up to b9292

This change only fixes a flaky test and does not alter production behavior. It carries no actionable merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the test now sends the workspace/configuration request over the connection that the language server shuts down. The raw summary confirms the test change matches this.…
Description check Passed The description explains the flaky CancelRequestAfterShutdownTest failure, its cause (a restart creating a second connection, with the request sent through the wrong client), the fix (keep the client,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: the test now sends the workspace/configuration request over the connection that the language server shuts down. The raw summary confirms the test change matches this. The title is specific and accurate, though it is somewhat long.

Full details: Description check

Explanation

The description explains the flaky CancelRequestAfterShutdownTest failure, its cause (a restart creating a second connection, with the request sent through the wrong client), the fix (keep the client, send through the stopped connection's client, check isDone with an answer), and test results. It matches the changeset.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3dae4bb3-3317-4f98-b63d-89cdd44c3a9b
Commits

Reviewing files that changed from the base of the PR and between 52bcd11 and b9292b7.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/CancelRequestAfterShutdownTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.80%. Comparing base (661b774) to head (b9292b7).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2162      +/-   ##
==========================================
+ Coverage   53.58%   53.80%   +0.21%     
==========================================
  Files         827      828       +1     
  Lines       34931    35000      +69     
  Branches     5469     7213    +1744     
==========================================
+ Hits        18717    18830     +113     
+ Misses      13425    13377      -48     
- Partials     2789     2793       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit cb29f9f into redhat-developer:main Nov 23, 2026
9 checks passed
lagergren added a commit that referenced this pull request Nov 24, 2026
…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.
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