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

Aberta
#67,073 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
230k
Forks
31.3k
Merge médio
5h 32min
PRs com merge (30d)
453

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de anomalyco/opencode

Todas as issues de anomalyco/opencode

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.