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

Rogue ruby-lsp related processes even after VS Code is quit #533

Open
tisba opened this issue Nov 8, 2024 · 6 comments
Open

Rogue ruby-lsp related processes even after VS Code is quit #533

tisba opened this issue Nov 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@tisba
Copy link

tisba commented Nov 8, 2024

Description

From time to time I notice that there are a bunch of ruby processes where I'm pretty sure they are related to ruby-lsp even if the Rails project got already closed or VS Code is no longer running (see details below).

Ruby LSP Information

VS Code Version

1.95.2

Ruby LSP Extension Version

0.8.13

Ruby LSP Server Version

0.21.3

Ruby LSP Addons

  • Ruby LSP Rails

Ruby Version

3.3.5

Ruby Version Manager

chruby

Installed Extensions

Click to expand
  • EditorConfig (0.16.4)
  • code-spell-checker (3.0.1)
  • copilot (1.243.0)
  • copilot-chat (0.22.2)
  • debugpy (2024.12.0)
  • dotenv (1.0.1)
  • even-better-toml (0.19.2)
  • go (0.42.1)
  • haml (1.4.1)
  • makefile-tools (0.11.13)
  • prettier-vscode (11.0.0)
  • python (2024.18.0)
  • remote-containers (0.388.0)
  • remote-explorer (0.4.3)
  • remote-server (1.5.2)
  • remote-ssh (0.115.0)
  • remote-ssh-edit (0.87.0)
  • remote-wsl (0.88.5)
  • rewrap (1.16.3)
  • ruby-extensions-pack (0.1.12)
  • ruby-lsp (0.8.13)
  • rust-analyzer (0.3.2172)
  • shellcheck (0.37.1)
  • solargraph (0.24.1)
  • sorbet-vscode-extension (0.3.37)
  • vscode-docker (1.29.3)
  • vscode-eslint (3.0.10)
  • vscode-fileutils (3.10.3)
  • vscode-github-actions (0.27.0)
  • vscode-graphviz (0.0.9)
  • vscode-kubernetes-tools (1.3.18)
  • vscode-markdownlint (0.56.0)
  • vscode-proto3 (0.5.5)
  • vscode-rdbg (0.2.2)
  • vscode-remote-extensionpack (0.26.0)
  • vscode-standard (2.1.3)
  • vscode-todo-highlight (1.0.5)
  • vscode-typescript-next (5.8.20241106)
  • vscode-yaml (1.15.0)
  • vsliveshare (1.0.5941)

Ruby LSP Settings

Click to expand
Workspace
{
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  }
}
User
{
  "enableExperimentalFeatures": true,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "chruby"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "useLauncher": false,
  "featureFlags": {}
}

Reproduction steps

Unavailable at this time.

I'm not sure if there is something specific I'm doing that leads to the issue. From time to time I just notice that there are a bunch of ruby processes running where I'm either 100% sure (~/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.23/lib/ruby_lsp/ruby_lsp_rails/server.rb) or pretty sure (~/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch […]) that they are spawned/related to ruby-lsp. I'm only using ruby-lsp from within VSCode.

There must be something off with process cleanup. Especially after quitting VS Code I'd expect all spawned processes to be properly terminated.

This output is from VS Code being terminated (properly quit, closing all windows before, no crashes reported, etc) – ps aux:

tisba            69979   0.0  0.0 410170688   1776   ??  S    Wed06PM   0:01.48 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/lib /Users/tisba/src/rails_project/spec/mailers/previews /Users/tisba/src/rails_project/app/controllers /Users/tisba/src/rails_project/app/decorators /Users/tisba/src/rails_project/app/helpers /Users/tisba/src/rails_project/app/lib /Users/tisba/src/rails_project/app/mailers /Users/tisba/src/rails_project/app/models /Users/tisba/src/rails_project/app/sandbox /Users/tisba/src/rails_project/app/serializers /Users/tisba/src/rails_project/app/validators /Users/tisba/src/rails_project/db
tisba            69978   0.0  0.0 410190144   1472   ??  S    Wed06PM   0:01.37 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/app/views
tisba            69977   0.0  0.0 410163520   1376   ??  S    Wed06PM   0:01.31 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/spec/factories
tisba            69976   0.0  0.0 410171712   1504   ??  S    Wed06PM   0:01.48 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/config/locales
tisba            69975   0.0  0.0 411842656   4144   ??  Ss   Wed06PM   0:00.62 /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.23/lib/ruby_lsp/ruby_lsp_rails/server.rb
tisba            69974   0.0  0.0 411361424   3520   ??  S    Wed06PM   0:00.39 /Users/tisba/.rubies/ruby-3.3.5/bin/ruby bin/rails runner /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.23/lib/ruby_lsp/ruby_lsp_rails/server.rb start
tisba            69929   0.0  0.0 412429648   3584   ??  S    Wed06PM   0:07.84 /Users/tisba/.gem/ruby/3.3.5/bin/ruby-lsp
tisba            59817   0.0  0.0 410171712   1776   ??  S    Wed03PM   0:01.82 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/lib /Users/tisba/src/rails_project/spec/mailers/previews /Users/tisba/src/rails_project/app/controllers /Users/tisba/src/rails_project/app/decorators /Users/tisba/src/rails_project/app/helpers /Users/tisba/src/rails_project/app/lib /Users/tisba/src/rails_project/app/mailers /Users/tisba/src/rails_project/app/models /Users/tisba/src/rails_project/app/sandbox /Users/tisba/src/rails_project/app/serializers /Users/tisba/src/rails_project/app/validators /Users/tisba/src/rails_project/db
tisba            59816   0.0  0.0 410173760   1472   ??  S    Wed03PM   0:01.64 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/app/views
tisba            59815   0.0  0.0 410179904   1776   ??  S    Wed03PM   0:01.81 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/lib /Users/tisba/src/rails_project/spec/mailers/previews /Users/tisba/src/rails_project/app/controllers /Users/tisba/src/rails_project/app/decorators /Users/tisba/src/rails_project/app/helpers /Users/tisba/src/rails_project/app/lib /Users/tisba/src/rails_project/app/mailers /Users/tisba/src/rails_project/app/models /Users/tisba/src/rails_project/app/sandbox /Users/tisba/src/rails_project/app/serializers /Users/tisba/src/rails_project/app/validators /Users/tisba/src/rails_project/db
tisba            59814   0.0  0.0 410173760   1472   ??  S    Wed03PM   0:01.66 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/app/views
tisba            59813   0.0  0.0 410182976   1376   ??  S    Wed03PM   0:01.76 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/spec/factories
tisba            59812   0.0  0.0 410163520   1504   ??  S    Wed03PM   0:01.69 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/config/locales
tisba            59811   0.0  0.0 411842496   3888   ??  Ss   Wed03PM   0:00.64 /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.23/lib/ruby_lsp/ruby_lsp_rails/server.rb
tisba            59810   0.0  0.0 410164544   1376   ??  S    Wed03PM   0:02.07 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/spec/factories
tisba            59809   0.0  0.0 410173760   1504   ??  S    Wed03PM   0:02.13 /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/src/rails_project/config/locales
tisba            59728   0.0  0.0 411212880   3280   ??  S    Wed03PM   0:00.38 /Users/tisba/.rubies/ruby-3.3.5/bin/ruby bin/rails runner /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.23/lib/ruby_lsp/ruby_lsp_rails/server.rb start
tisba            59599   0.0  0.0 412176912   3584   ??  S    Wed03PM   0:09.46 /Users/tisba/.gem/ruby/3.3.5/bin/ruby-lsp
@tisba tisba added the bug Something isn't working label Nov 8, 2024
@andyw8 andyw8 changed the title Rouge ruby-lsp related processes even after VS Code is quit Rogue ruby-lsp related processes even after VS Code is quit Nov 8, 2024
@andyw8
Copy link
Contributor

andyw8 commented Nov 8, 2024

👋
There are various things that could potentially cause this, but we'd really need a consistent reproduction case to investigate.

(btw I corrected the spelling in the PR title to make it easier to search for this issue).

@tisba
Copy link
Author

tisba commented Nov 8, 2024

👋 There are various things that could potentially cause this, but we'd really need a consistent reproduction case to investigate.

Yeah, I figured as much. I'm not sure I have seen a consistent pattern yet. These processes don't seem to cause issues and are not consuming enough resources to be noticeable right away. I'm trying to think of something to detect this sooner so I can relate that to something I'm doing.

To the point of processes running after VS Code has been terminated: Isn't there a mechanism to ensure that child processes are properly terminated? Depending on how the extension spawns those children that should be something that happens automatically by the OS, right? 🤔

(btw I corrected the spelling in the PR title to make it easier to search for this issue).

Thank you 🙈

@andyw8
Copy link
Contributor

andyw8 commented Nov 8, 2024

To the point of processes running after VS Code has been terminated: Isn't there a mechanism to ensure that child processes are properly terminated? Depending on how the extension spawns those children that should be something that happens automatically by the OS, right? 🤔

Here's what we do on shutdown:

unless ENV["RAILS_ENV"] == "test"
at_exit do
if @wait_thread.alive?
sleep(0.5) # give the server a bit of time if we already issued a shutdown notification
force_kill
end
end
end

@tisba
Copy link
Author

tisba commented Nov 9, 2024

Disclaimer: I have almost no idea how VS Code extensions or ruby-lsp is structured, so bare with me :)

My current theory is that VS Code's Code Helper (Plugin) process crashes (which actually happens some times for me). Looking at the process tree, it looks like ruby-lsp processes are children of that process:

-+= 50801 tisba /Applications/Visual Studio Code.app/Contents/MacOS/Electron
 |--- 50802 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (GPU).app/Contents/MacOS/Code Helper (GPU) --type=gpu-process --user-data-dir=/Users/tisba/Library/Application Support/Code --gpu-preferences=UAAAAAAAAAAgAAAEAAAAAAAAAAAAAAAAAABgAAEAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAA --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version --seatbelt-client=30
 |--- 50803 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --user-data-dir=/Users/tisba/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version --seatbelt-client=30
 |--- 50805 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --type=renderer --user-data-dir=/Users/tisba/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --app-path=/Applications/Visual Studio Code.app/Contents/Resources/app --enable-sandbox --enable-blink-features=HighlightAPI --disable-blink-features=FontMatchingCTMigration, --lang=en-US --num-raster-threads=4 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --renderer-client-id=4 --time-ticks-at-unix-epoch=-1730984992351564 --launch-time-ticks=167985976350 --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version --vscode-window-config=vscode:bd6ed9f8-a918-4e68-b2c1-416cb35bd806 --seatbelt-client=64
 |--- 50859 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --user-data-dir=/Users/tisba/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version
 |--- 50860 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --user-data-dir=/Users/tisba/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version
 \-+- 50900 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --dns-result-order=ipv4first --inspect-port=0 --user-data-dir=/Users/tisba/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,15518530713489516058,4187484149676038975,262144 --enable-features=ScreenCaptureKitPickerScreen,ScreenCaptureKitStreamPickerSonoma --disable-features=CalculateNativeWinOcclusion,MacWebContentsOcclusion,SpareRendererForSitePerProcess,TimeoutHangingVideoCaptureStarts --variations-seed-version
   |-+= 51048 tisba /Users/tisba/.gem/ruby/3.3.5/bin/ruby-lsp    
   | \-+- 51067 tisba /Users/tisba/.rubies/ruby-3.3.5/bin/ruby bin/rails runner /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/server.rb start
   |   \-+- 51071 tisba spring server | forge | started 13 mins ago   
   |     \-+= 51072 tisba spring app    | forge | started 13 mins ago | development mode      
   |       |--- 51118 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/config/locales
   |       |--- 51119 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/spec/factories
   |       |-+= 51120 tisba /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/server.rb      
   |       | |--- 51121 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/config/locales
   |       | |--- 51122 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/spec/factories
   |       | |--- 51126 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/app/views
   |       | \--- 51129 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/lib /Users/tisba/Documents/work/rails-app/spec/mailers/previews /Users/tisba/Documents/work/rails-app/app/controllers /Users/tisba/Documents/work/rails-app/app/decorators /Users/tisba/Documents/work/rails-app/app/helpers /Users/tisba/Documents/work/rails-app/app/lib /Users/tisba/Documents/work/rails-app/app/mailers /Users/tisba/Documents/work/rails-app/app/models /Users/tisba/Documents/work/rails-app/app/sandbox /Users/tisba/Documents/work/rails-app/app/serializers /Users/tisba/Documents/work/rails-app/app/validators /Users/tisba/Documents/work/rails-app/db
   |       |--- 51123 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/app/views
   |       \--- 51125 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/lib /Users/tisba/Documents/work/rails-app/spec/mailers/previews /Users/tisba/Documents/work/rails-app/app/controllers /Users/tisba/Documents/work/rails-app/app/decorators /Users/tisba/Documents/work/rails-app/app/helpers /Users/tisba/Documents/work/rails-app/app/lib /Users/tisba/Documents/work/rails-app/app/mailers /Users/tisba/Documents/work/rails-app/app/models /Users/tisba/Documents/work/rails-app/app/sandbox /Users/tisba/Documents/work/rails-app/app/serializers /Users/tisba/Documents/work/rails-app/app/validators /Users/tisba/Documents/work/rails-app/db
   |--- 51056 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/tisba/.vscode/extensions/github.vscode-github-actions-0.27.0/dist/server-node.js --node-ipc --clientProcessId=50900
   |--- 51073 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/tisba/.vscode/extensions/streetsidesoftware.code-spell-checker-3.0.1/packages/_server/dist/main.cjs --node-ipc --clientProcessId=50900
   |--- 51127 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/tisba/.vscode/extensions/dbaeumer.vscode-eslint-3.0.10/server/out/eslintServer.js --node-ipc --clientProcessId=50900
   \--- 51128 tisba /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=50900

When I kill pid 50900 to simulate a "hard crash" of the helper process, 51071 gets adopted by launchd:

-+- 51071 tisba spring server | forge | started 17 mins ago   
 \-+= 51072 tisba spring app    | forge | started 17 mins ago | development mode      
   |--- 51118 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/config/locales
   |--- 51119 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/spec/factories
   |--- 51123 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/app/views
   |--- 51125 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/lib /Users/tisba/Documents/work/rails-app/spec/mailers/previews /Users/tisba/Documents/work/rails-app/app/controllers /Users/tisba/Documents/work/rails-app/app/decorators /Users/tisba/Documents/work/rails-app/app/helpers /Users/tisba/Documents/work/rails-app/app/lib /Users/tisba/Documents/work/rails-app/app/mailers /Users/tisba/Documents/work/rails-app/app/models /Users/tisba/Documents/work/rails-app/app/sandbox /Users/tisba/Documents/work/rails-app/app/serializers /Users/tisba/Documents/work/rails-app/app/validators /Users/tisba/Documents/work/rails-app/db
   \-+= 65775 tisba /Users/tisba/.gem/ruby/3.3.5/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/server.rb      
     |--- 65776 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/config/locales
     |--- 65777 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/spec/factories
     |--- 65778 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/app/views
     \--- 65779 tisba /Users/tisba/.gem/ruby/3.3.5/gems/rb-fsevent-0.11.2/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/tisba/Documents/work/rails-app/lib /Users/tisba/Documents/work/rails-app/spec/mailers/previews /Users/tisba/Documents/work/rails-app/app/controllers /Users/tisba/Documents/work/rails-app/app/decorators /Users/tisba/Documents/work/rails-app/app/helpers /Users/tisba/Documents/work/rails-app/app/lib /Users/tisba/Documents/work/rails-app/app/mailers /Users/tisba/Documents/work/rails-app/app/models /Users/tisba/Documents/work/rails-app/app/sandbox /Users/tisba/Documents/work/rails-app/app/serializers /Users/tisba/Documents/work/rails-app/app/validators /Users/tisba/Documents/work/rails-app/db

So bin/ruby-lsp is terminated, but spring and its children keep running, which is kind of the point of spring. So I guess this is an issue with ruby-lsp in combination with spring. If I comment out spring in bin/rails and repeat the SIGKILL on the plugin helper it works as expected, no left over processed adopted by launchd:

#!/usr/bin/env ruby
# load File.expand_path("spring", __dir__)
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"

That might be worth something for the troubleshooting guide, or maybe

stdin, stdout, stderr, wait_thread = Bundler.with_original_env do
Open3.popen3("bundle", "exec", "rails", "runner", "#{__dir__}/server.rb", "start")
end
could set DISABLE_SPRING=1? Alternatively is there a way to detect that ruby-lsp is running bin/rails, like an environment variable? That way one could disable spring if you don't want to make ruby-lsp aware of spring itself.

@tisba
Copy link
Author

tisba commented Nov 21, 2024

While not very elegant, adding this to bin/rails works for now:

unless ENV.keys.none? { |k| k.include?("VSCODE") }
  load File.expand_path("spring", __dir__)
end

If there is a more elegant solution, I'm all ears :)

ADDED This has of course the downside, that the integrated VS Code terminal won't use spring either :(

@andyw8
Copy link
Contributor

andyw8 commented Nov 21, 2024

(moving to the rails-lsp-rails repo as this seems specific to that add-on)

@andyw8 andyw8 transferred this issue from Shopify/ruby-lsp Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants