Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
The forwarder.js implementation in the Remote Containers extension has two compounding issues that cause severe CPU degradation on the local machine:
- Per-forwarder kubectl polling: Each port forwarder spawns its own kubectl get pod … -o json every 1 second to monitor pod liveness. This polling runs independently per forwarder rather than being shared.
- Zombie localhost:0 forwarders on EADDRINUSE fallback: When a port forward (e.g., localhost:32903) fails with EADDRINUSE (because another Cursor window already holds that port), the extension spawns a fallback forwarder on localhost:0 (OS auto-assigned port). These fallback forwarders are not cleaned up when the window is closed, and each one continues its 1-second kubectl polling indefinitely.
What happened
I work with Kubernetes pods and frequently open the same pod in multiple Cursor windows (for worktrees, PVC inspection, etc.). Over time, localhost:0 fallback forwarders accumulated silently.
When I investigated, 26 zombie forwarders were running, each executing kubectl get pod every second — meaning 26 kubectl processes were being spawned per second. CPU idle had dropped to ~17%.
After manually killing the 26 forwarders, CPU idle recovered to ~53%. However, 2 forwarders immediately respawned — traced to 2 currently open windows, confirming the active reproduction path.
Evidence from logs
The EADDRINUSE → localhost:0 fallback sequence is visible in the Remote - Dev Containers extension logs. Fixed port forward fails with EADDRINUSE, immediately followed by a localhost:0 forwarder being spawned.
Root cause location
~/.cursor/extensions/anysphere.remote-containers-1.0.32/dist/scripts/forwarder.js
Steps to Reproduce
- Open a Kubernetes pod in Cursor window A. Ports (e.g., 32903 and 8000) are auto-forwarded.
- Open the same pod in Cursor window B. The extension attempts to forward the same ports, hits EADDRINUSE, and spawns localhost:0 fallback forwarders.
- Close window B. The fallback forwarders remain alive with their kubectl polling.
- Repeat steps 2–3 several times (or simply open/close windows over days of normal use).
- Observe CPU usage climbing as zombie forwarders accumulate.
Expected Behavior
- Forwarders spawned by a window should be terminated when that window closes.
- Pod liveness monitoring should use kubectl get pod --watch (or the Kubernetes watch API) instead of polling every 1 second.
- Pod liveness monitoring should be shared across forwarders, not duplicated per-forwarder.
- If a port is already forwarded by another window, the extension should detect this and skip the redundant forward rather than falling back to localhost:0.
Operating System
MacOS
Version Information
anysphere.remote-containers extension (v1.0.32)
Cursor Version: 2.6.22
Does this stop you from using Cursor
Yes - Cursor is unusable