Skip to content

Provide API for add-ons to register only unique watchers #3145

Open
@vinistock

Description

@vinistock

We are currently allowing add-ons to register file watchers freely, but I just realized this is not a good approach for a few reasons.

  1. It is better to register for file watching only once with multiple patterns, rather than creating several separate registrations
  2. If registration IDs are not unique, they will cause orphan LSP client objects that continue to receive file change events as we saw in Notify file events failed - Client is not running #3137
  3. If add-ons register for the same pattern, like the RuboCop add-on registering for .rubocop.yml (same as the Ruby LSP), then the server will receive duplicate changes for those patterns

We need to provide a proper API for file watching registration that provides the LSP with the opportunity to:

  1. Register them all at once
  2. Ensure ID uniqueness (it will be a single registration, so that is fixed by default)
  3. Verify that patterns are unique to avoid receiving the duplicate notifications in the first place

I haven't prototyped anything, but I think we may need a breaking change to expose a nicer API to add-ons. Instead of passing the outgoing_queue as a Thread::Queue, it would be better to have our own abstraction so that we can limit what add-ons can pass and ensure that bugs like these cannot happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpinnedThis issue or pull request is pinned and won't be marked as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions