knowns icon indicating copy to clipboard operation
knowns copied to clipboard

kn browser leaks conhost.exe/OpenConsole.exe indefinitely via unthrottled docker stats / dotnet --version polling (Windows)

Open linda-agi opened this issue 3 months ago • 1 comments

Description

kn browser leaks a conhost.exe/OpenConsole.exe process roughly every 0.5s while it stays running, with no upper bound. Left running for a few minutes, this accumulates hundreds of orphaned processes and measurably degrades the host system (high process count, elevated CPU/handle usage).

Environment

  • OS: Windows 11
  • Knowns: v0.29.0 (npm install, npm i -g knowns)
  • Repo: a project containing both a docker-compose.yml and a .NET project (i.e. Knowns detects both a Docker and a .NET environment during project scan)

Repro steps

  1. In a repo with both Docker Compose and a .NET project present, run:
    kn browser
    
  2. Leave it running (do not touch the terminal).
  3. Watch process count for conhost.exe + OpenConsole.exe over time.

Observed

Process count for conhost.exe+OpenConsole.exe grows continuously and linearly for as long as kn browser stays alive. Sample measurement, checked every 15s with nothing else running:

T+0s   : 58
T+15s  : 85   (+27)
T+30s  : 119  (+34)
T+45s  : 143  (+24)
T+60s  : 171  (+28)
T+75s  : 199  (+28)
T+90s  : 233  (+34)

~2 new console-host processes/sec, unbounded, for the entire observation window. knowns.exe process count itself stayed flat (2 processes) the whole time — it isn't spawning more copies of itself, something inside it is looping.

Root cause (identified via live process-tree inspection)

Caught the following commands being invoked repeatedly by the running knowns.exe, each one still holding a fresh (not-yet-orphaned) parent PID at capture time:

docker.exe stats --all --no-trunc --no-stream --format "{{ json .}}"
dotnet.exe --version

This looks like an environment/health-check poller (presumably feeding a "Docker: running" / ".NET: vX" status widget on the dashboard) that:

  1. Runs on a very tight interval (effectively unthrottled, ~2/sec aggregate)
  2. Spawns a brand new console host for every invocation instead of reusing one / redirecting without allocating a console (e.g. no CREATE_NO_WINDOW / no console-host reuse)
  3. Never reaps the console host after the child command exits — it becomes a permanent orphan (reparented by Windows to svchost.exe -k DcomLaunch)

Killing the knowns.exe process immediately stops all further growth (confirmed multiple times) — the count only ever climbs while it's alive, so the loop lives entirely inside the running process, not in some detached side process.

Suggested fix

  • Throttle the environment-status poll interval (a few seconds is plenty for a "is Docker/is dotnet available" indicator — no reason to poll every ~0.5s)
  • Reuse a single console host / spawn child processes with CREATE_NO_WINDOW so no per-invocation console is allocated on Windows
  • Make sure the poller actually terminates/reaps each child + its console host before the next tick

Impact

On a repo with both Docker and .NET detected, simply leaving kn browser open (e.g. in a background terminal while working) silently exhausts system process/handle resources over time — went from a normal baseline (~550 total processes) to 700+ within 90 seconds in testing, with no indication in the CLI output that anything was wrong.

linda-agi avatar Aug 12 '26 01:08 linda-agi

Thanks for the detailed report and process-tree evidence — that made this much easier to pin down.

I opened a PR here: https://github.com/knowns-dev/knowns/pull/139

The direct fix is commit 2ecd073 (fix(windows): throttle runtime probes):

  • Caches LSP/runtime inventory probes so browser/status polling no longer reruns expensive probes every tick.
  • Routes spawned probe commands through a shared process helper.
  • On Windows, starts child probe processes without allocating a console window, so probes like dotnet --version should no longer create recurring conhost.exe / OpenConsole.exe instances.
  • Adds tests for runtime probe caching and Windows no-window process attributes.

Two follow-up commits are also included:

  • 1dd66db improves MCP task/time mutation responsiveness by deferring derived indexing to best-effort background work.
  • d7beb0a refreshes README badges/integration guidance and adds uninstall documentation.

Expected result: leaving kn browser idle in a repo with Docker Compose and .NET present should no longer grow conhost.exe / OpenConsole.exe counts linearly. I’ll keep this open until Windows retest confirms it.

howznguyen avatar Aug 12 '26 10:08 howznguyen