Skip to content

fix: wait to start server during language server restart - #1289

Closed
IntegerLimit wants to merge 4 commits into
redhat-developer:mainfrom
IntegerLimit:lsp-restart-wait
Closed

IntegerLimit wants to merge 4 commits into
redhat-developer:mainfrom
IntegerLimit:lsp-restart-wait

Conversation

@IntegerLimit

@IntegerLimit IntegerLimit commented Sep 21, 2025 •

Copy link
Copy Markdown
Contributor

This PR makes the following change to the restart function in LSP Wrapper:

  • Waits for server to stop before starting

This fixes an edge case discovered whilst working on GroovyScript Plugin: due to the server taking long to process the shutdown request, stopping the server takes until the timeout runs out (5 seconds), resulting in the following sequence of events if the server was restarted:

  • Server stop called
  • Server start called, server starts
  • Connection Provider stop called, server stops again

Furthermore, even if the server is in the stopped state, starting the server via the console would always result in these events. The only method of recovering from this (prior to this fix) is to disable and re-enable the language server through external means (IDE restart, settings change).

This PR is confirmed to fix the above issue.

@IntegerLimit IntegerLimit changed the title Fix Edge Cases in LSP Restarts bug: fix edge case in language server restart Sep 21, 2025
@IntegerLimit IntegerLimit changed the title bug: fix edge case in language server restart fix: edge case in language server restart Sep 21, 2025
@IntegerLimit IntegerLimit changed the title fix: edge case in language server restart fix: wait to start server during language server restart Sep 21, 2025
@IntegerLimit

Copy link
Copy Markdown
Contributor Author

As of the latest commit, the server is once again stopped before starting, in restart, if the status is stopped. The change seemed to break some error recoverability.

@angelozerr

Copy link
Copy Markdown
Contributor

I have tested your PR by starting , stoppings again and again with the menu and it seems it is working pretty well!

Congrats it is a nice fix.

As of the latest commit, the server is once again stopped before starting, in restart, if the status is stopped. The change seemed to break some error recoverability.

What do you mean? Your fix is not correct and you have some other problem?

@IntegerLimit

Copy link
Copy Markdown
Contributor Author

I have tested your PR by starting , stoppings again and again with the menu and it seems it is working pretty well!

Congrats it is a nice fix.

As of the latest commit, the server is once again stopped before starting, in restart, if the status is stopped. The change seemed to break some error recoverability.

What do you mean? Your fix is not correct and you have some other problem?

Thank you!

The second point was due to a change I made in the initial commit, where I skipped the stop call if the status was stopped. I reverted this change due to discovering it caused some issues with error recoverability.

However, in the current state of the PR, I have discovered no issues.

@angelozerr

angelozerr commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor

@IntegerLimit since long time I wanted to revisit this start , stop restart server because as you have noticed it can have some trouble, like the stop which kill process created by a restart when for instance shutdown takes some times.

The main problem is because wrapper share in fields some context like lspStreamProvider which is bad.

I think more and more that we should have a given context instance which hosts this provider, the launchFuture etc.

Today wen server is starting it initialize lspStreamProvider, launchFuture in fields and old stop could cancel them which is again bad.

With context strategy, initialize of the server will have a context instance and stop will have an another context instance and could kill process, cancel launchFuture without killing the process created by the initialize step.

I would like to implement my idea with context because even with your PR, you can have some trouble with piped closed error.

I can reproduce the problem by emulating a slowInputStteam class which slows down the input stream of the language server.

I will ping you when I will have a PR.

@IntegerLimit

Copy link
Copy Markdown
Contributor Author

Ok, that sounds good. I did notice some further edge cases sometimes, even with my fix, so a rework of the stop/start system is good.

@angelozerr

Copy link
Copy Markdown
Contributor

@IntegerLimit could you please try #1303

@IntegerLimit

Copy link
Copy Markdown
Contributor Author

Will try as soon as I can.

@angelozerr

Copy link
Copy Markdown
Contributor

Please wait again.... It is not finished.

@angelozerr

Copy link
Copy Markdown
Contributor

@IntegerLimit

Copy link
Copy Markdown
Contributor Author

Yes, that seems to have fixed the issue. Thanks!

@IntegerLimit

Copy link
Copy Markdown
Contributor Author

Closed as superseeded by 9ff4d64.

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