# Fix workspace diagnostics polling \(\#63336\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/ab7d21d4449165e794bd4a649bfa6b113ac192a9)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: ab7d21d4449165e794bd4a649bfa6b113ac192a9

Requested commit: ab7d21d4449165e794bd4a649bfa6b113ac192a9

Commit: ab7d21d4449165e794bd4a649bfa6b113ac192a9

Tree: a4d2b775dde5d397c099d8e90abf74e31d9544c1

Author: Kirill Bulatov

Committer: GitHub

## Message

```
Fix workspace diagnostics polling (#63336)

Closes https://github.com/zed-industries/zed/issues/62391

Workspace diagnostics were polled incorrectly:

* Workspace pulls were cancelled and re-sent every 120s.
Pyright-family servers hold the request open forever and re-analyze the
whole workspace on every new one, so the retry loop leaked memory; the
request is now kept open (long-poll), as the spec recommends.

* No re-trigger after a server closed a workspace pull.
ty closes the request when diagnostics change and expects the client to
re-pull
 
* `ServerCancelled` / `retriggerRequest` was ignored.
The spec defaults cancellation data to `{ retriggerRequest: true }`, so
these errors now retrigger workspace pulls and retry document pulls
instead of failing them.

* LSP error codes were erased with `anyhow!(message)`
Errors now carry a typed `lsp::ResponseError` through the chain,
replacing four copies of `ends_with(...)` matching against
rust-analyzer's literal message texts.

* Workspace partial results were not tied to their request.
Stale or numeric-token `$/progress` reports were applied as current data
and could poison `previousResultIds` until a server restart; reports are
now matched against the exact in-flight token.

* `interFileDependencies` was never read.
Every edit re-pulled all other open buffers even for servers declaring
no inter-file dependencies (e.g. ruff); cross-buffer pulls are now gated
on that capability.

* Cross-buffer pulls were unpaced.
All open buffers were pulled back-to-back after each edit debounce; they
are now paced at one document per 500ms.

* The failure valve killed workspace pulls permanently.
51 hard errors over a server's lifetime silently stopped its workspace
pulls until restart

* Concurrent refresh waiters could be dropped instantly.
The capacity-1 refresh channel resolved a second concurrent waiter to
`false` immediately, and request errors dropped queued refreshes;
waiters now queue and carry over to the retried pull.

Release Notes:

- Fixed basedpyright memory leak caused by incorrect workspace
diagnostics polling
```

## Parents

- [ad251e0a04e78670ea0d4c940bebcd7cfe19b6cb](https://git.cafe/gitcafe/zed/commit/ad251e0a04e78670ea0d4c940bebcd7cfe19b6cb?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/ab7d21d4449165e794bd4a649bfa6b113ac192a9?format=markdown)
