Skip to content

Start R language server only when needed and stop after 30s.#1708

Open
Fred-Wu wants to merge 1 commit into
REditorSupport:masterfrom
Fred-Wu:fix/lsp-lifecycle-management
Open

Start R language server only when needed and stop after 30s.#1708
Fred-Wu wants to merge 1 commit into
REditorSupport:masterfrom
Fred-Wu:fix/lsp-lifecycle-management

Conversation

@Fred-Wu
Copy link
Copy Markdown
Contributor

@Fred-Wu Fred-Wu commented May 14, 2026

Summary

This PR updates the R language server lifecycle so that the server starts only when an R-related document is opened, and shuts down after all R-related documents are closed.

This avoids keeping the language server running unnecessarily while still preserving the existing session if another R-related file is opened shortly after the last one is closed.

Main Changes

  • The language server no longer starts eagerly. It now starts only when an R-related file is opened.
  • When the last R-related file is closed, a 30-second shutdown timer is started.
  • If another R-related file is opened before the timer finishes, the shutdown is cancelled and the existing language server session is kept alive.
  • Before shutting down, the timer performs a final check of the currently open editors. If any R-related file is still open, shutdown is aborted.
  • This lifecycle behaviour works for both single-server mode and multi-workspace-server mode.

…vity

- Start the language server only when an R file is opened.
- Stop the server automatically 30 seconds after the last R file is closed.
- Cancel the shutdown timer if a new R file is opened within those 30 seconds.
- Fix "server disconnected" errors by double-checking that no R files are open exactly when the 30-second timer finishes, preventing the server from being accidentally killed while in use.
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.

1 participant