Skip to content

fix: end existing clients on new start and properly await stop#264

Merged
brandonspark merged 2 commits intodevelopfrom
brandon/kill-processes2
Sep 2, 2025
Merged

fix: end existing clients on new start and properly await stop#264
brandonspark merged 2 commits intodevelopfrom
brandon/kill-processes2

Conversation

@brandonspark
Copy link
Contributor

This PR makes it so:

  1. When starting a new language client (such as on workspace change), we properly .stop() the old one. Otherwise, we overwrite it and never can access its value again.
  2. We properly await the .stop() method.

Test plan:

Verified that processes do not pile up on workspace change. Remains to be seen for restart.

PR checklist:

  • Purpose of the code is evident to future readers
  • Tests included or PR comment includes a reproducible test plan
  • Documentation is up-to-date
  • A changelog entry was for any user-facing change
  • Change has no security implications (otherwise, ping security team)

If you're unsure about any of this, please see:

Copy link

@Friss Friss left a comment

Choose a reason for hiding this comment

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

I was just looking at the code to see if this stop needed an await.

@brandonspark brandonspark merged commit dc627cf into develop Sep 2, 2025
11 checks passed
@brandonspark brandonspark deleted the brandon/kill-processes2 branch September 2, 2025 17:08
semgrep-ci bot pushed a commit to semgrep/semgrep that referenced this pull request Sep 2, 2025
This PR changes all our current usages of Lwt (in the LSP) to Eio.
Changes include:

1. Using the Eio otel collector instead of the Lwt otel collector
2. Stop using preemptive threads
3. Using Eio instead of Lwt to send metrics

As a side effect, this also fixes the process leak issue in the IDE
caused by processes not terminating properly for users using
experimental LS.

## Test plan:

CI and tested with [this
PR](semgrep/semgrep-vscode#264) to the
`semgrep-vscode` repo.

The video below shows:

1. No process leak when switching workspace folders
2. No process leak when restarting the server

https://www.loom.com/share/052ff2e037ec49f6ac113b2c1741dc07

Traces are also sent properly:
https://app.datadoghq.com/apm/trace/bfa65e995e7f6acb80bca8c20b6fbbab?graphType=waterfall&shouldShowLegend=true&spanID=5188063030673080386&traceQuery=

synced from Pro 36ebf21debb09562c6dc6f05ed83a16f9a895f0c
semgrep-ci bot pushed a commit to semgrep/semgrep that referenced this pull request Sep 3, 2025
This PR changes all our current usages of Lwt (in the LSP) to Eio.
Changes include:

1. Using the Eio otel collector instead of the Lwt otel collector
2. Stop using preemptive threads
3. Using Eio instead of Lwt to send metrics

As a side effect, this also fixes the process leak issue in the IDE
caused by processes not terminating properly for users using
experimental LS.

## Test plan:

CI and tested with [this
PR](semgrep/semgrep-vscode#264) to the
`semgrep-vscode` repo.

The video below shows:

1. No process leak when switching workspace folders
2. No process leak when restarting the server

https://www.loom.com/share/052ff2e037ec49f6ac113b2c1741dc07

Traces are also sent properly:
https://app.datadoghq.com/apm/trace/bfa65e995e7f6acb80bca8c20b6fbbab?graphType=waterfall&shouldShowLegend=true&spanID=5188063030673080386&traceQuery=

synced from Pro 36ebf21debb09562c6dc6f05ed83a16f9a895f0c
nmote pushed a commit to semgrep/semgrep that referenced this pull request Sep 3, 2025
This PR changes all our current usages of Lwt (in the LSP) to Eio.
Changes include:

1. Using the Eio otel collector instead of the Lwt otel collector
2. Stop using preemptive threads
3. Using Eio instead of Lwt to send metrics

As a side effect, this also fixes the process leak issue in the IDE
caused by processes not terminating properly for users using
experimental LS.

## Test plan:

CI and tested with [this
PR](semgrep/semgrep-vscode#264) to the
`semgrep-vscode` repo.

The video below shows:

1. No process leak when switching workspace folders
2. No process leak when restarting the server

https://www.loom.com/share/052ff2e037ec49f6ac113b2c1741dc07

Traces are also sent properly:
https://app.datadoghq.com/apm/trace/bfa65e995e7f6acb80bca8c20b6fbbab?graphType=waterfall&shouldShowLegend=true&spanID=5188063030673080386&traceQuery=

synced from Pro 36ebf21debb09562c6dc6f05ed83a16f9a895f0c
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.

3 participants