fix(oxfmt): destroy existing Tinypool before re-initialising in LSP mode#24183
Closed
tsushanth wants to merge 1 commit into
Closed
fix(oxfmt): destroy existing Tinypool before re-initialising in LSP mode#24183tsushanth wants to merge 1 commit into
tsushanth wants to merge 1 commit into
Conversation
initExternalFormatter() was called multiple times during a long-lived LSP session (e.g. on config reload or project switch) without destroying the previous Tinypool instance. The orphaned child_process workers accumulate indefinitely, reaching 1000+ processes and 30+ GB RAM after hours of use. Guard the function: if a pool already exists, destroy it before creating the new one. disposeExternalFormatter() already does this on CLI exit; this applies the same pattern to the init path. Fixes oxc-project#24147
Member
|
Thank you. I'll take it over in #24197. I felt it would be better to keep it as it is rather than re-init it every time. |
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.
Problem
initExternalFormatter()creates a newTinypoolinstance each time it is called. In--lspmode the process stays alive indefinitely, and the Rust side callsinitExternalFormatter()again on config reload or project switch. The old pool and itschild_processworkers are never destroyed, so they accumulate.Observed in production: 1,500+ orphaned
node tinypool/.../process.jsprocesses, 30+ GB RAM after several hours of normal LSP usage.Fix
Add the same guard that
disposeExternalFormatter()already applies on CLI exit — if a pool exists, destroy it before constructing the new one:Fixes #24147