Skip to content

Wait for language servers instead of sleeping in tests - #2335

Merged
akurtakov merged 1 commit into
eclipse-wildwebdeveloper:masterfrom
akurtakov:wait-for-language-servers
Dec 3, 2026
Merged

akurtakov merged 1 commit into
eclipse-wildwebdeveloper:masterfrom
akurtakov:wait-for-language-servers

Conversation

@akurtakov

@akurtakov akurtakov commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Several tests slept 2 to 4 seconds (10 seconds in total in TestAngular) to give the language server time to start before editing the document or sending requests.

This adds Utils.waitForLanguageServer(document, serverId, timeout), which waits until the given server is running and connected to the document, and until all the other servers of the document are initialized. If that does not happen in time, it fails the test with a clear message. It replaces:

  • the startup sleeps in TestAngular, TestLanguageServers, TestTypeScript, TestJsTs, TestTypeScriptFormattingPreferences and TestJSONResultLimitPreference;
  • the three copies of the same wait in TestAstro and TestMarkdown, two of which ignored the result.

Notes:

  • Waiting for all servers of the document matters because requests through LanguageServers.forDocument() wait for every server of the document, e.g. ESLint next to JS/TS. They time out while one is still starting.
  • The rename tests also wait until the server highlights all occurrences. Inline rename collects them with a 1 second documentHighlight request, and only renames the occurrence at the caret if that times out.

The 1.5 s sleeps waiting for preference changes to reach the server are left as they are.

Locally (Linux) all 62 tests pass. The changed test classes pass 3 runs pinned to a single CPU, which reproduced the earlier Jenkins failures before these fixes. In those classes the waits save about 14 s compared with the sleeps.

@akurtakov
akurtakov force-pushed the wait-for-language-servers branch 2 times, most recently from 69990b0 to 3c1d5d3 Compare December 3, 2026 05:09
Several tests slept 2 to 10 seconds to give the language server time
to start. Add Utils.waitForLanguageServer(), which waits until the
server is running and connected to the document, and until all the
other servers of the document are initialized, and fails the test
otherwise. Use it instead of those sleeps and of the copies of the same
wait in TestAstro and TestMarkdown, two of which did not check the
result.

Waiting for all servers matters because requests through
LanguageServers.forDocument() wait for every server of the document,
e.g. ESLint next to JS/TS, and time out while one is still starting.

The rename tests also wait until the server highlights all occurrences,
as inline rename collects them with a 1 second documentHighlight
request and only renames the one at the caret if it times out.

Assisted-by: Anthropic Claude Code (claude-opus-5-5)
@akurtakov
akurtakov force-pushed the wait-for-language-servers branch from 3c1d5d3 to 98b42ec Compare December 3, 2026 05:17
@akurtakov
akurtakov merged commit 754d0da into eclipse-wildwebdeveloper:master Dec 3, 2026
9 checks passed
@akurtakov
akurtakov deleted the wait-for-language-servers branch December 3, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants