fix(workspace): cap live Monaco models to stop the listener leak - #75
Closed
posthog[bot] wants to merge 3 commits into
Closed
posthog[bot] wants to merge 3 commits into
posthog[bot] wants to merge 3 commits into
Conversation
Keep the active file plus a bounded, recently-used set of models and recreate cold files on demand, so the workspace model count stays under Monaco's 200-listener leak monitor. Reconcile disposal against Monaco's global model registry so a model that falls out of the manager's map cannot linger with its listener attached. Generated-By: PostHog Desktop Task-Id: d961cb21-a653-45b3-8bf0-a4048d12da3c
Generated-By: PostHog Desktop Task-Id: d961cb21-a653-45b3-8bf0-a4048d12da3c
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
posthog Bot
added a commit
to tscircuit/tscircuit.com
that referenced
this pull request
Aug 11, 2026
Bump @tscircuit/monaco-code-editor to the build that caps the number of live Monaco text models, so large packages in the web editor no longer create one model per file and cross Monaco's 200-listener leak monitor. Pairs with tscircuit/monaco-code-editor#75. Generated-By: PostHog Desktop Task-Id: d961cb21-a653-45b3-8bf0-a4048d12da3c
The committed src/styles.compiled.css was stale relative to `bun run build:css`, which failed the CI stylesheet check. Regenerate it. The drift predates this branch and is unrelated to the model-manager change. Generated-By: PostHog Desktop Task-Id: d961cb21-a653-45b3-8bf0-a4048d12da3c
Author
|
🔕 Closing this PR because the linked PostHog report was suppressed. If that wasn't intended, restore the report in PostHog and reopen this PR. |
This branch was successfully deployed
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
Error. Reported across two browsers (Chromium and Firefox) and two deploys.MonacoWorkspaceModelManagerkeeps one liveTextModelper workspace file. Each model adds a listener, so a workspace with a few hundred files reaches the threshold on its own. Model count grows with the file count, so this is a memory leak, not only a warning.Map.getModelfell back to Monaco's global registry, so any model that fell out of the map stayed alive with its listener attached.Changes
DEFAULT_MAX_LIVE_MODELS = 100). The manager keeps the active file plus a recently-used set; the least-recently-used models past the cap are disposed.syncFilesnow takes the active file and never evicts it.getModelrebuilds an evicted file's model from its last known content, so file open, navigation, and workspace search still resolve every file — search results and cross-file replace are unchanged.Trade-off
Verification
bun run typecheckpasses.bun test— 60 pass, 0 fail.biome formatclean.Reported from tscircuit.com error tracking. A pin bump in tscircuit.com follows this merge.