Skip to content

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

Merged
datho7561 merged 2 commits into
redhat-developer:mainfrom
shin19991207:fix-2481
Jul 14, 2026
Merged

Fix race condition when executing Java workspace commands during standard server startup#4462
datho7561 merged 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

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and fixes the problem. Thanks, Morgan!

@datho7561 datho7561 merged commit a267c61 into redhat-developer:main Jul 14, 2026
2 checks passed
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')

2 participants