fix: MonacoLspClient should implement IDisposable#5339
Open
apatenotre wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[LSP] Make
MonacoLspClientdisposableFixes #5340.
MonacoLspClient.createFeatures()already returns anIDisposablecovering every Monaco provider registration the client installs, but the constructor discards it and the class has nodispose()method. Embedders with a component lifecycle (React, Vue, …) can't release the registrations, so each remount leaks providers, leading to a permanent "Loading…" entry in hover/code-action widgets contributed by the stale providers (whose transport is closed and whosehover(...)/codeAction(...)requests never resolve).This PR stashes the disposable on the instance and exposes
dispose().Verification done locally
In a Next.js + Monaco app that builds against
monaco-editor0.55.1(which bundles this client), I patchedMonacoLspClient.prototypeto mirror this fix and confirmed:Notes
monaco-lsp-client/currently has no test infrastructure (notest/folder, no test script inpackage.json, no test framework dep). Happy to add one if you pick a framework; the assertion is straightforward: stubmonaco.languages.register*Providerto capture the returned disposables, construct + dispose the client, assert each captured disposable is now disposed.LspCapabilitiesRegistry/TextDocumentSynchronizer/LspConnection, but those don't register Monaco providers and don't contribute to the observed leak. Scoping this PR to the immediate user-visible bug.dispose()is idempotent becauseDisposableStore.dispose()is idempotent (no-op after first call).