Skip to content

Terminate Copilot language server process tree on shutdown - #505

Open
Dietrich Travkin (travkin79) wants to merge 5 commits into
microsoft:mainfrom
travkin79:fix-408-stop-CLS-on-close
Open

Dietrich Travkin (travkin79) wants to merge 5 commits into
microsoft:mainfrom
travkin79:fix-408-stop-CLS-on-close

Conversation

@travkin79

@travkin79 Dietrich Travkin (travkin79) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Related to #408

While the CLS is busy, closing Eclipse hangs invisibly (window closed, JVM still running):
UserPreferenceService.dispose() waits without limit for conversation/persistence. On RHEL this request was
answered after 11 min 41 s; only then were shutdown/exit sent. A busy CLS also does not react to
shutdown/exit, so it can outlive Eclipse, keep using 100 % CPU and accumulate across restarts. During
shutdown, late requests could even start a new CLS.

Changes

  • Saving the chat preferences on shutdown waits at most 2 s for the CLS, also while a preference load is still
    waiting for the CLS. On timeout, only the chat input history of the session may not be saved; other preferences
    are saved when they change.
  • On stop, wait up to 6 s (LSP4E waits 5 s for the shutdown response), then force-kill the CLS and its
    descendant processes (e.g. MCP servers), including those started during the wait.
  • Do not start the CLS while the Copilot core bundle is stopping.

Overlaps with #455 (bounded shutdown flush), but can be merged on its own.

Verification

Verified on RHEL 9.6 with ~400 projects: closing Eclipse while the CLS was busy previously took ~12 minutes
(until the CLS went idle). With this PR, Eclipse exits after ~8 s and the CLS process is gone:

!ENTRY com.microsoft.copilot.eclipse 1 0 2026-10-23 18:50:13.567
!MESSAGE [Info] Language server did not provide the persistent path in time, skipping

!ENTRY org.eclipse.lsp4e 2 0 2026-10-23 18:50:18.600
!MESSAGE The server did not stop after 5 seconds

!ENTRY com.microsoft.copilot.eclipse 1 0 2026-10-23 18:50:19.600
!MESSAGE [Info] Copilot language server did not exit in time, killing it

Copilot AI 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.

🟡 Changes recommended

Preference-monitor contention can still block shutdown indefinitely, and processes spawned during the grace period can escape cleanup.

2 open issues
What changed in this PR

This PR addresses the shutdown symptoms associated with #408 by limiting preference-path waits and adding process-tree cleanup for an unresponsive Copilot language server.

Changes:

  • Adds a two-second shutdown timeout for preference-path requests.
  • Waits up to six seconds for server exit, then forcibly terminates the server and captured descendants.
  • Blocks server startup while the core bundle is stopping and adds regression tests.
File Description
com.microsoft.copilot.eclipse.ui/​src/​com/​microsoft/​copilot/​eclipse/​ui/​chat/​services/​UserPreferenceService.java Applies the preference timeout during disposal.
com.microsoft.copilot.eclipse.ui/​src/​com/​microsoft/​copilot/​eclipse/​ui/​chat/​services/​ChatBaseService.java Adds timeout-aware preference-path retrieval.
com.microsoft.copilot.eclipse.ui.test/​src/​com/​microsoft/​copilot/​eclipse/​ui/​chat/​services/​UserPreferenceServiceTest.java Tests disposal with an unanswered persistence request.
com.microsoft.copilot.eclipse.core/​src/​com/​microsoft/​copilot/​eclipse/​core/​lsp/​LsStreamConnectionProvider.java Prevents server startup during core shutdown.
com.microsoft.copilot.eclipse.core/​src/​com/​microsoft/​copilot/​eclipse/​core/​lsp/​CopilotLanguageServerConnection.java Adds bounded exit waiting and forced process cleanup.
com.microsoft.copilot.eclipse.core.test/​src/​com/​microsoft/​copilot/​eclipse/​core/​lsp/​LsStreamConnectionProviderTests.java Tests the shutdown startup guard.
com.microsoft.copilot.eclipse.core.test/​src/​com/​microsoft/​copilot/​eclipse/​core/​lsp/​CopilotLanguageServerProcessTests.java Tests termination of an unresponsive server and its child.

Review effort: Balanced

Copilot AI 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.

🟡 Changes recommended

Shutdown can still block indefinitely on monitor acquisition despite a successful path timeout; the deadline must cover locking or safely skip saving while loading, with a regression test using independently completed persistence futures.

1 open issue
2 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@travkin79

Copy link
Copy Markdown
Contributor Author

Hi Sheng Chen (@jdneo),
Do you have some time to also review and merge this PR? Do you see any issues left?

@travkin79

Copy link
Copy Markdown
Contributor Author

Hi Sheng Chen (@jdneo),
After fixing some review findings in a PR, the PR checks are not run automatically (CI run, AI code review, etc.). Could these automated checks be activated for copilot-for-eclipse, i.e. be executed after each PR push? I think, that would reduce effort on your side (you'd review PRs after all automatically identified findings were fixed) and would provide earlier feedback to contributors.

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