Idle server keeps burning CPU forever after each chat prompt (0.159.0 and 0.160.1, Windows)
Describe the bug
After a chat prompt finishes, the server process keeps burning CPU while completely idle. On my machine (Windows, native binary): a persistent ~1-core busy-loop thread appears after a single prompt; in real editor sessions hot threads accumulate with activity — I measured 16 cores / 18 pegged threads on a 24-core machine after a tool-heavy chat session — along with unbounded memory growth (working set 400→800 MB over ~30 min, sawtooth pattern = constant allocation + GC churn). Restarting the server resets it; it comes back after chatting. Observed the same on 0.159.0 and 0.160.1.
To Reproduce
Protocol-level, no editor required — any client speaking the stdio JSON-RPC is enough:
- Start the server and complete the
initialize/initializedhandshake with a workspace (models sync, MCP servers start as usual). - Let everything settle. Idle CPU drops to ~0 and stays there (verified 7+ minutes with MCP servers running).
- Send a single
chat/prompt— even "Reply with exactly: OK. Do not use any tools." with zero tool calls — and let the turn finish (chat/statusChanged→ idle). - Watch the server process in an OS/process monitor: idle CPU is now a persistent ~1 core and never subsides (8+ minutes headless; hours in a real emacs session).
Control: the same setup without any prompt stays at ~0 idle CPU indefinitely. A second identical prompt did not add a second core in the headless run, but in real sessions with many tool calls the hot-thread count keeps growing (18 measured).
Expected behavior
Idle CPU returns to ~0 after the prompt completes.
Doctor
eca-emacs: c9f06b0 (2026-09-14) | server: eca-native-windows-amd64 0.160.1 and 0.159.0 | emacs: GNU Emacs 31.1 (build 2, x86_64-w64-mingw32) | z-ai provider (anthropic api), 3 MCP servers over stdio bridges.
Additional context
How it was observed/measured (Windows 11, 24 logical cores):
- Per-thread CPU deltas (
Process.Threads→TotalProcessorTimesampled a few seconds apart): every hot thread pegged at ~89% of one core each; total thread count grows with session activity (60→93 over 30 min). - Working set sawtooth between ~300 and ~800 MB on the affected server — steady allocation with GC reclaiming, monotonic growth overall.
--log-level debugshows nothing periodic from the hot loop itself; the only idle-periodic log activity ([secrets]re-reading the netrc every ~6 s) also happens in the zero-CPU control run, so it's unrelated.- MCP ruled out: the reproduction works with the full MCP server set running, and the initialize-only control with the same MCP set idles at ~0.
- Guess on the mechanism: something in the prompt lifecycle never terminates (stream reader, idle-stream watchdog, async loop) and keeps allocating.
I have a minimal headless Node repro harness on windows if useful — happy to attach.
@qwota I took a look (on my NixOS) and could not repro or find anything that keeps using CPU after prompt is finished, can you share detailed steps to repro that? I hope it's not something that happens only in windows
I think this is a Windows-specific issue since it requires no special setup to reproduce. I've had it since I started using ECA, right from server version 158. I just open a chat, type something, or run a slash command, and the "eca" process starts hogging the CPU. You must have noticed this.
I'll try to debug it soon to find out exactly what triggers the CPU spike: whether it's an issue with all Windows builds or just my specific setup (MCP, tools).
Either way, I can't use it properly right now, since the ECA server quickly eats up ~70% of my CPU and stays at that level.
@qwota interesting! I'd suggest testing the non graalvm image first so we can really separate JVM from native binary first.
You can find it in the releases as eca.jar or just do a bb debug-cli to build yourself.
LMK if there is anything to help, I really found weird this much CPU waste
Thanks for checking! I tested the JVM build (eca.jar on JDK 24, --log-level debug) with the same headless client — same behavior, so not graalvm-specific.
Deterministic repro without any prompt or LLM call:
- Any client speaking the stdio JSON-RPC:
initialize→initializedwith a workspace. chat/openan existing persisted chat that has at least one message (resume).- Do nothing. CPU grows in steps of roughly +1 core every 30–40 s, unbounded: 1 → 5.8 cores over 5 minutes, heap 600 MB → 2.1 GB. Native image grows the same way.
Thread dumps (jcmd <pid> Thread.print, two dumps 3 s apart) name the spinner: every hot ForkJoinPool-1-worker-* is carrying a virtual thread wedged in the JDK HttpClient TLS reader, spinning forever on a connection that has no more data:
sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:504)
javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:673)
jdk.internal.net.http.common.SSLFlowDelegate$Reader.unwrapBuffer(SSLFlowDelegate.java:556)
jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:452)
jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:283)
jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
java.util.concurrent.ThreadPerTaskExecutor$TaskRunner.run
java.lang.VirtualThread.run
Cumulative per-thread cpu= from the dump header confirms the ladder: 141 s / 124 s / 86 s / 71 s / 43 s / 18 s across workers — matching the +1-core steps.
Two independent leak paths I could separate:
- Unbounded growth engine: a native-http MCP server (
urltransport, plumcp) pointing at a gateway that streams SSE. With that single MCP server disabled in config, the samechat/openrepro idles at a flat 0.00 cores / constant memory indefinitely. Each retry/keep-alive cycle of that connection (~30–40 s) wedges another reader. I also see the socket stuck in CLOSE_WAIT on the client side. - Smaller per-request leak: even with all MCP off, one completed streaming LLM request leaves one wedged reader (~1 core). That's the only leak that survives with no MCP configured.
Guess why it didn't repro for you: without a native-http MCP against an SSE gateway you only get the small per-request leak, which settles in ~20–60 s after the turn finishes and is easy to miss unless you watch the process for a minute after.
Happy to attach the headless harness (Node, stdio JSON-RPC, built-in CPU sampler, prompt|resume modes) and both thread dumps.
Step-by-step repro with the attached harness
Harness: eca-synth4-client.js (cross-platform sampler: PowerShell on Windows, /proc on Linux, ps on macOS). Attach it plus eca-dump1.txt/eca-dump2.txt.
- Pick any directory to be the workspace (the harness registers
cwdas the single workspace folder; chat cache is keyed per workspace). - Seed a chat once (this also shows the small leak — CPU settles at ~1 core after the turn instead of ~0):
cd <workspace> && node eca-synth4-client.js <path-to-eca-binary> seed promptWait forPHASE: done(~5 min). One LLM call is spent here. - Find the seeded chat id:
<path-to-eca> read-chat --workspace <workspace>→ take thesynth4-…id (any existing chat with ≥1 message works). - Repro (no LLM call):
node eca-synth4-client.js <path-to-eca-binary> repro resume <chatId>Expected: afterPHASE: chat/openthecpu=lines climb in ~+1-core steps every 30–40 s (1.0 → 1.9 → 2.6 → …) with no bound; memory climbs too. Server is killed by the harness at t+300 s (edit the lastsetTimeoutfor longer runs). - Control: disable the native-http MCP server (or use a config with no
url-transport MCP against an SSE gateway) and repeat step 3 — CPU stays flat at 0.00.
For the JVM build: run with ECA_JAVA pointing at a real JDK java.exe (not a PATH shim — on Windows the Oracle javapath shim forks the real JVM as a child process and you'd sample the wrong PID): ECA_JAVA=<jdk>/bin/java node eca-synth4-client.js <path>/eca.jar repro resume <chatId>
While it spins, jcmd <pid> Thread.print shows the stacks quoted above; per-thread cumulative cpu= in the dump headers gives the ladder.
@qwota I'm afraid this might be a jdk issue:
JDK-8374557 "Enhance TLS connection handling" (fixed 2026-01-23). Not Windows specific, I hit it on Linux.
Trigger: a peer that sends TLS close_notify while keeping the TCP connection open, with bytes still left in the read buffer. That's what an SSE gateway does when it drops a stream, and it explains your CLOSE_WAIT sockets. In that state SSLFlowDelegate$Reader.unwrapBuffer's CLOSED case never drains src nor sets completing, so the processData loop can't exit.
I'm checking if bumping graal or something would fix it
Oh, God! It’s quiet in my room again.
@qwota nice, I bumped graal, LMK if any issues!