Files
pvemanager/backend/app/api/proxmox/vms.py
Dilshod Rasulov 7d60afb9fa
Some checks failed
Backend Tests / pytest (Python 3.12) (push) Failing after 1m22s
Deploy to Production / Trigger production update (push) Failing after 11s
SonarCloud / SonarCloud Analysis (push) Failing after 2m39s
fix(console): stop leaking termproxy sessions and orphaned terminals
Opening an LXC console left a failed task on the Proxmox node:

  failed waiting for client: timed out
  TASK ERROR: command '/usr/bin/termproxy 5900 ... vzctlconsole101' failed

connectTerminal() called GET /api/{sid}/container/{vid}/terminal first,
which creates a termproxy session on the node, but only the `node` field
of the response was used - port and ticket were discarded. The ws
endpoint then created a second termproxy session and connected to that
one. Nobody ever attached to the first, so Proxmox waited ~10s for a
client and failed the task.

The console also rendered a black screen in dev: React StrictMode mounts
the effect twice, connect* are async, and the effect cleanup ran before
they had assigned wsRef/termRef, so it had nothing to clean up. Two
xterm instances ended up in the same container - the first one filled
the viewport while the live one was pushed out of the overflow-hidden
area, which is why the badge read "connected" over an empty screen.

- drop the redundant REST call; the ws endpoint owns the termproxy
- remove the now unused GET /api/{server_id}/container/{vmid}/terminal
- add a per-session cancellation guard: a stale connect closes its own
  socket and disposes its own terminal without touching refs that may
  already point at the live session
- route mount and the reconnect button through a single startSession()
  that cancels and tears down the previous session first
- apply the same guard to the node shell page
2026-08-21 21:06:44 +05:00

165 KiB