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

Notify file events failed - Client is not running #3137

Closed
mioruggieroguida opened this issue Feb 5, 2025 · 5 comments · Fixed by #3144
Closed

Notify file events failed - Client is not running #3137

mioruggieroguida opened this issue Feb 5, 2025 · 5 comments · Fixed by #3144
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@mioruggieroguida
Copy link

Description

Ruby LSP Information

Ruby LSP Information

VS Code Version

1.96.4

Ruby LSP Extension Version

0.8.20

Ruby LSP Server Version

0.23.6

Ruby LSP Add-ons

  • RuboCop

Ruby Version

3.2.2

Ruby Version Manager

rbenv

Installed Extensions

Click to expand
  • copilot (1.263.0)
  • copilot-chat (0.23.2)
  • debugpy (2024.14.0)
  • less-aggressive-spinel-theme (0.0.3)
  • markdown-preview-enhanced (0.8.15)
  • ms-teams-vscode-extension (5.12.1)
  • python (2024.23.2025012801)
  • ruby-lsp (0.8.20)
  • vscode-pylance (2025.1.102)
  • vscode-yaml (1.15.0)

Ruby LSP Settings

Click to expand
Workspace
{
  "formatter": "auto"
}
User
{
  "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": "auto"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "featureFlags": {}
}

Reproduction steps

  1. Restart LSP Server
  2. Use autocompletion (this works fine)
  3. Save file
  4. I keep getting the error below and I need to restard the server

Code snippet or error message

2025-02-05 09:14:03.324 [info] (MortarApp) [Error - 09:14:03] Notify file events failed.
2025-02-05 09:14:03.324 [info] (MortarApp)   Message: Client is not running
  Code: -32096 
@mioruggieroguida mioruggieroguida added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Feb 5, 2025
@andyw8
Copy link
Contributor

andyw8 commented Feb 5, 2025

@mioruggieroguida Is this a large project? Roughly how many Ruby files?

@mioruggieroguida
Copy link
Author

@andyw8 Maybe this helps

cloc --include-lang=Ruby .  
     890 text files.
     580 unique files.                                          
     548 files ignored.

github.com/AlDanial/cloc v 2.04  T=0.41 s (921.0 files/s, 123854.7 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Ruby                           374           6408          11425          32463
-------------------------------------------------------------------------------
SUM:                           374           6408          11425          32463

The above does not include gems

@vinistock
Copy link
Member

Thank you for the issue, #3144 will fix it.

graphite-app bot pushed a commit that referenced this issue Feb 6, 2025
### Motivation

Closes #3137

We were using the same registration ID for two different file watchers. That made VS Code override the entry, but one of them became a dangling object that didn't get appropriately cleaned up when the LSP shuts down.

Because that old file watcher was still active, the LSP client itself was not cleared either as a reference was still being held and then notifications for `didChangeWatchedFiles` were sent to a client that was already stopped, resulting in the `Notify file events failed` message.

We should always use unique IDs when registering file watchers.

### Implementation

I did 3 small things:

1. Ensured unique IDs for registering the watchers
2. Started watching `.rubocop`, which we watched before but I missed in my refactor PR
3. Started ensuring that we're only processing changes once

The last point is necessary because add-ons may register for watching the same patterns as one another or as the Ruby LSP and that results in duplicate changes being sent to the server.

The most optimal solution is #3145, but that is going to require more effort, so let's just fix the issue for now.

### Automated Tests

Added a test and verified manually that the issue is gone.
graphite-app bot pushed a commit that referenced this issue Feb 6, 2025
…3142)

### Motivation

While studying #3137, I noticed there were some disposables not being handled properly. Whatever we push to `context.subscriptions` will only be disposed when the extension is deactivated, which means we continue to waste memory and resources unnecessarily.

We need the client and workspace to better own their disposables.

### Implementation

I tried minimizing the times where we invoke `context.subscriptions`, so that problems of this nature are easier to spot.

There were two command registrations that were leaking and two client hooks.
@mioruggieroguida
Copy link
Author

Just installed 0.9.2 and this is still happening. I noticed that the PR was merged.

2025-02-09 08:30:02.008 [info] (MortarApp) [Error - 08:30:02] Notify file events failed.
2025-02-09 08:30:02.008 [info] (MortarApp)   Message: Client is not running
  Code: -32096 
2025-02-09 08:30:02.008 [info] (MortarApp) [Error - 08:30:02] Notify file events failed.
2025-02-09 08:30:02.008 [info] (MortarApp)   Message: Client is not running
  Code: -32096 
2025-02-09 08:30:02.008 [info] (MortarApp) [Error - 08:30:02] Notify file events failed.
2025-02-09 08:30:02.008 [info] (MortarApp)   Message: Client is not running
  Code: -32096 
2025-02-09 08:30:02.009 [info] (MortarApp) [Error - 08:30:02] Notify file events failed.
2025-02-09 08:30:02.009 [info] (MortarApp)   Message: Client is not running
  Code: -32096 

@vinistock
Copy link
Member

v0.9.2 is the extension version. This bug was in the server and is released in v0.23.9.

You can follow these instructions to upgrade the server or wait until an automatic upgrade occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants