Repository navigation
fix(lsp): keep large symbol results from exhausting the lsp_symbols heap - #393
Merged
Merged
Conversation
Collaborator
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 15, 2026
Closed
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5766bf8df2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The workspace symbol picker opens with an empty query, which typescript-language-server answers with every symbol in the project. lsp_symbols then passed that whole result to its batch helper, and the Husk runtime charges every binding of an array its full size even though the data is shared, so the call counted as a second full copy. For the reporter's ~44 MB result that exceeded the 64 MiB plugin heap, and the plugin was quarantined until Red restarted. The plugin now slices results to the 4096 rows a picker shows before handing them to its batch helpers, and its status line says how many results were left out. Results larger than the plugin heap itself still need a host-side bound, tracked in #394. Fixes #388
fcoury
force-pushed
the
fix/workspace-symbol-cap
branch
from
October 15, 2026 16:13
5766bf8 to
0d5039b
Compare
fcoury
added a commit
that referenced
this pull request
Oct 15, 2026
…eap (#398) * fix(plugins): trim or drop request results too large for a plugin's heap A request result that did not fit in the receiving plugin's 64 MiB Husk heap failed while binding the callback argument, before any plugin code ran, and the registry quarantined the plugin. A large TypeScript project's empty workspace-symbol query (about 60,000 symbols, roughly 130 MB once decoded) still stopped lsp_symbols this way after #393. The runtime now compares each result with the plugin's free heap before calling back. Results that fit are delivered unchanged. Oversized DocumentSymbols, WorkspaceSymbols and References results keep the leading entries that fit in half of the free heap, leaving room for one more binding of the list, which the runtime charges again. Any other oversized result is dropped: the plugin stays active and Red shows a warning attributed to it. Successful results of those three requests now carry `total`, the entry count before trimming, which lsp_symbols uses for its truncation status. That field opens host API 0.20.0, recorded in the change manifest and documented in PLUGIN_API.md; 0.19.0 packages keep loading. Fixes #394 * fix(plugins): trim symbol and reference lists past half the plugin heap A list that fits the heap can still leave the plugin no room to build picker items from it, which quarantined lsp_symbols at 28,000 symbols.
This was referenced Oct 15, 2026
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.
Opening the workspace symbol picker (
Space w) in a large TypeScript project quarantined thelsp_symbolsplugin. After that,Space wdid nothing for the rest of the session, which looked like a crash. The reporter's log shows the cause:HUSK-R0001: Husk heap byte limit exceeded (requested 43816023 bytes with 43820382 of 67108864 bytes live).Fixes #388.
Cause
workspace/symbolquery. typescript-language-server sends that to tsserver without a result limit, so it returns every symbol in the project. A symbol takes about 2.2 KB of plugin heap, so the reporter's result used about 44 MB of the 64 MB limit.start_symbol_batch. Husk charges each binding of an array its full size, even though the data is shared rather than copied (#395). That call was charged a second 44 MB and hit the limit.Fix
The bundled
lsp_symbolsplugin now cuts results down to the 4096 rows a picker can show before passing them to its batch helpers. So the helpers never hold more than 4096 entries, whatever the server returns. When results are cut, the status line says how many, for example4096 symbols (results truncated: first 4096 of 20000; type to narrow). The same applies to references.This PR doesn't change the plugin host API. An earlier version also capped results in the host and added a
totalfield. Review pointed out that this would change the released 0.19 contract for third-party plugins, so it's been dropped.Limitation
The plugin can only protect itself once a result is already in its heap. A result too large for the 64 MB heap on its own, roughly 25,000 or more symbols, still fails before any plugin code runs. Handling that needs a bound on the host side, which #394 tracks. That work will open host API 0.20.0 and decide what an oversized result means for older plugins.
Testing
lsp_symbols_workspace_symbols_survive_results_larger_than_the_picker: runs the real bundled plugin against a 20,000-symbol workspace symbol result, about the reporter's size. Onmain's plugin it fails with the reporter's exact error (HUSK-R0001, 44 MB requested with 44 MB live). With this change it passes and shows the truncation status.clippy --all-targets --all-features -D warnings,fmt --check, and--self-checkall pass.