Server keeps watching old local plugin trees after a config path swap

Offen
#67,073 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
backend

Rechercherichtung

Start with packages/core/src/plugin/module.ts, packages/core/src/config/plugin/source.ts, and packages/core/src/filesystem/watcher.ts to understand watch ownership and shared subscriptions. Reproduce the config-path swap, then add a regression test that directly counts active JS streams. Done means obsolete source paths are unsubscribed after reconciliation, while shared helpers and recoverable configured sources remain watched.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area/plugins platform/linux type/feature version/v2

Changing plugins from one local source tree to another activates the replacement, but the running server keeps the old tree's file-watcher streams until the owning project location closes. Repeated swaps to new paths add more retained streams. Returning to a previously seen path does not add a second set for that path.

How to reproduce: Configure a local plugin outside the config discovery directories. Give it an entrypoint that imports a local helper. Copy the tree to a second path, then change plugins to point to the copy without restarting the server. Wait for the replacement to become active. Check for active streams under both trees, or check for watcher stopped records for the old tree after settling. Repeat with a third path. The old tree should stop being watched unless another active plugin needs one of its files.

What we measured: On a Linux service based on 2.4.2, with 12 local plugins across 20 loaded project directories, each tree generated 4,480 in-process subscribe requests across 224 watched paths. The first swap left all 224 outgoing native watch resources active; they stopped only at service shutdown. The patched build released all 224 outgoing paths on each of three swaps. Equivalent consumers already share native watch resources; 4,480 is a count of JS subscribe requests, not a kernel watch count or a direct census of live JS objects. A smaller regression test counted active JS streams directly and found the old root, entrypoint and helper still subscribed before the fix.

Source: The path is present on dev at e1d864a24dec1507160e430597eae53487358c21. PluginModule.watch forks each source-file stream into the supervisor's scope and never removes its path from watched. watchConfiguredSources does the same for configured roots. The watcher shares an underlying resource but adds a PubSub subscription for each consuming stream.

Proposed fix: Track watch fibers by path. After reconciliation, stop the streams and drop the source records no longer needed by any active or recoverable failed local source. Keep shared helpers watched, and reconcile configured root watches separately so manifest edits still work. This also covers the stale-watch lifetime noted in #62894 for missing imports, without removing automatic recovery for a still-configured source. We can share the patch and regression test.

Vorherrschende Sprache
TypeScript
Sterne
230k
Forks
31.3k
Ø Merge
5 Std. 32 Min.
Gemergte PRs (30 T.)
453

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus anomalyco/opencode

Alle Issues in anomalyco/opencode

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.