Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes vscode-java extension never be ready (always spin) #1056

Closed
testforstephen opened this issue Sep 9, 2019 · 0 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1170
Assignees
Labels

Comments

@testforstephen
Copy link
Collaborator

When upgrade java-debug extension and reload the workspace, the language server status is hanging at spin, never be ready.

After an investigation at the initialization logic, i found this is a sequence issue.

Below is the client code. languageClient.onReady() is resolved once the client received initialize response for initialize request.

languageClient.onReady().then(() => {
    languageClient.onNotification(StatusNotification.type, (report) => {
	switch (report.type) {
	    case 'Started':
		item.text = '$(thumbsup)';
		p.report({ message: 'Finished' });
		lastStatus = item.text;
		commands.executeCommand('setContext', 'javaLSReady', true);
		resolve({
		    apiVersion: '0.2',
		    javaRequirement: requirements,
		    status: report.type,
		   registerHoverCommand,
		});
		break;

In server code (see InitHandler.java), the status notification is possibly sent before initialize response, that will cause the client never receive the Ready notification.

		triggerInitialization(rootPaths);
		Integer processId = param.getProcessId();
		if (processId != null) {
			JavaLanguageServerPlugin.getLanguageServer().setParentProcessId(processId.longValue());
		}
		try {
			Collection<String> bundleList = getInitializationOption(initializationOptions, BUNDLES_KEY, Collection.class);
			BundleUtils.loadBundles(bundleList);
		} catch (CoreException e) {
			// The additional plug-ins should not affect the main language server loading.
			JavaLanguageServerPlugin.logException("Failed to load extension bundles ", e);
		}
  • Firstly, the InitHandler will invoke the function triggerInitialization(rootPaths) to trigger an async job to import the workspace, which will be responsible for sending status notification to client.
  • Secondly, the InitHandler will invoke the function BundleUtils.loadBundles(bundleList) to load third party bundles.
  • Finally return Initialize response.

This logic works when BundleUtils.loadBundles(bundleList) run very quickly. But if there are bundles upgrading new version, it will need uninstall the old one, and then install the new one. This operation will take more time. That will possibly cause Ready notification is sent before Initialize response, so that the client never received the correct server status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants