Skip to content

Fix race condition when executing Java workspace commands during standard server startup#4462

Open
shin19991207 wants to merge 2 commits into
redhat-developer:mainfrom
shin19991207:fix-2481
Open

Fix race condition when executing Java workspace commands during standard server startup#4462
shin19991207 wants to merge 2 commits into
redhat-developer:mainfrom
shin19991207:fix-2481

Conversation

@shin19991207

Copy link
Copy Markdown
Member

Fixes #2481

There is a race condition in extension start-up where java.execute.workspaceCommand can be invoked while the standard Java language server is still starting. During that startup window, standardClient.getClient() can be undefined, but the command handler calls standardClient.getClient().sendRequest(...). That can throw:

TypeError: Cannot read properties of undefined (reading 'sendRequest')

This is especially visible when standard server startup is delayed or skipped by startup decisions such as build tool conflict handling (i.e. open a project with both build.gradle and pom.xml existed).

This PR prevents java.execute.workspaceCommand from using the Java language client before it is initialized by:

  • making java.execute.workspaceCommand wait for an active standard server startup before sending the workspace command request
  • returning with a warning if the standard client is still unavailable after startup is skipped/cancelled, for example when the user dismisses the build tool conflict prompt
  • reordering postExtensionStartInit(...) so the initial standard-server startup decision happens before commands that depend on the standard client are registered

…r startup

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@shin19991207 shin19991207 requested a review from datho7561 July 13, 2026 16:41
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.

TypeError: Cannot read properties of undefined (reading 'sendRequest')

1 participant