-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(cli): invalidate per-instance config caches on global config update #7179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,21 @@ export namespace State { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Reset all cache-only entries (those without dispose callbacks) across all | ||
| * instances. This invalidates derived state like Config, Agent, Provider, | ||
| * etc. without tearing down side-effectful resources (MCP connections, | ||
| * sessions, file watchers, etc.). | ||
| */ | ||
| export function resetCaches() { | ||
| for (const entries of recordsByKey.values()) { | ||
| for (const [init, entry] of entries) { | ||
| if (entry.dispose) continue | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: This also deletes long-lived per-instance stores that intentionally have no disposer, including |
||
| entries.delete(init) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export async function dispose(key: string) { | ||
| const entries = recordsByKey.get(key) | ||
| if (!entries) return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Config-backed services with disposers will not reload
State.resetCaches()only invalidates entries without a dispose callback. Services likeMCP.state,LSP.state, andFileWatcher.statereadConfig.get()during initialization and do have disposers, so they keep running with the old global config. Changes like enabling/disabling MCP or LSP servers, or updating watcher ignore rules, will not take effect until the instance is fully disposed.