[Bug] PegaProx 1.1.0 SSE reconnect storm causes request amplification
Describe the bug
PegaProx 1.1.0 can enter an SSE reconnect storm after a transient token/stream failure. In Firefox behind the Tailscale Serve → nginx reverse-proxy path, one stale dashboard tab repeatedly requests /api/sse/token and /api/sse/updates, while the UI reports “Live updates disconnected”. The reconnect callback fetches a token and then calls connectSSE(), which fetches another token; the health timer can call connectSSE() concurrently. There is no single-flight reconnect guard.
This produced thousands of requests per minute on our appliance. During a separate systemd stop at 05:25:51 UTC, the old process also hit gevent.exceptions.BlockingSwitchOutError in the signal-handler call to http_server.stop() and exited status 1. The logs do not prove the SSE storm requested that restart.
Steps to Reproduce
- Run PegaProx 1.1.0 behind a reverse proxy (Tailscale Serve → nginx → HTTPS PegaProx).
- Sign in with a cluster inventory present.
- Leave the Firefox dashboard open through a transient SSE/token failure (expired session, proxy interruption, or service interruption).
- Observe
POST /api/sse/tokenandGET /api/sse/updatesin DevTools/nginx logs. - Observe overlapping reconnects, repeated token/stream requests, and the reconnect banner.
Expected behavior
Only one reconnect should be in flight, with bounded backoff and no duplicate EventSource objects or token requests. If SSE cannot recover, the UI should cleanly fall back to polling without a stale disconnect warning.
Environment
- PegaProx Version: 1.1.0 (build 2026.08.30; package 1.1.0-1)
- Installation Method: Debian appliance package
- OS: Debian 13 (trixie)
- Browser: Firefox 155 on macOS
- Behind Reverse Proxy? Tailscale Serve → nginx
- UI? Modern Layout
Logs
Representative nginx counts from the affected tab (UTC):
- 05:12 — 4,924 token POSTs; 2,083 SSE GETs
- 05:13 — 2,537 token POSTs; 1,187 SSE GETs
- 05:25:51 — systemd stop;
BlockingSwitchOutErrorfromhttp_server.stop() - 05:25:53 — systemd started PegaProx again
Screenshots
Not attached; the browser network log and server journal are the primary evidence.
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
AI assistance disclosure
OpenAI Codex (GPT-5) assisted with log analysis, source inspection, patch drafting, and test orchestration. All changes were reviewed and tested by the operator.
Follow-up after the initial containment:
The first polling build still aborted overview reads at 12 seconds, while the server-side aggregate status read can take up to 20 seconds plus the resources read. That produced nginx 499s and a shell-only dashboard even though the appliance was healthy.
Fixed in deployment by increasing the polling timeout to 35 seconds, adding a single-flight guard to the 30-second overview poll, rebuilding the bundle, and bumping the service-worker cache to v6. SSE remains intentionally disabled as the stability containment.
Validation: Firefox now shows 7/7 clusters, 7/7 nodes online, 37 running VMs, 22 stopped VMs, and fresh timestamps. All overview status/resource requests returned 200 after the patch; no browser SSE traffic or new BlockingSwitchOutError was observed.
Follow-up validation and second defect found (2026-09-06)
The deployed polling containment stopped the SSE reconnect churn, but a separate overview data-gating defect remained: the UI fetched /api/global/summary but ignored it, calculating estate totals only after all per-cluster status/resource calls settled. One slow or reconnecting cluster could leave the overview looking empty while the aggregate endpoint was already ready.
Fix applied:
- Wired the existing aggregate response into
AllClustersOverview. - Estate totals render immediately; cluster cards and Top Resources continue updating independently.
- No VM, Proxmox, network, or service configuration changed; the daemon was not restarted.
Validation:
- Deployed at
2026-09-06T14:43:53Zafter backing up the previous bundle. - Fresh Firefox reload showed 7/7 clusters, 37 running VMs, 22 stopped VMs, 13% CPU, and 64% RAM.
- Authenticated
/api/global/summaryreturned HTTP 200 in 0.15–0.47s. - The next polling cycle returned HTTP 200 for all cluster status/resource calls;
pegaprox.servicestayed active with zero restarts and no BrokenPipe, traceback, or 503 entries in the checked window.
AI assistance disclosure: Assisted by OpenAI Codex (GPT-5) for log analysis, source inspection, patch drafting, and test orchestration. All changes were reviewed, applied, and tested by the operator.
Thanks, I looked first but must have missing them.
1.1.1 is out and carries the fix.
The shutdown path was rebuilt on si458's approach from #780: http_server.stop() runs in its own greenlet with a bounded join instead of blocking on the gevent hub, the racing sys.exit(0) is gone, and the SSH WebSocket subprocess is terminated with the parent instead of being left reparented to init. A SIGTERM now exits 0 in about two seconds with a clean log.
Thanks for the report and for digging through the existing issues first. https://opencollective.com/pegaprox if it's worth a few euros to you.
— Marcus
Post-1.1.1 follow-up: remaining All Clusters telemetry failure
I am adding this to #784 instead of opening another issue because it arose from the same incident. Please let me know whether you would prefer it split into a separate, narrowly scoped issue.
Environment and disclosure
- PegaProx package:
1.1.1-1 - Debian 13 appliance
- Firefox 155 on macOS
- Tailscale Serve → nginx
- Modern Layout
This was not a pristine installation: local polling and guest-memory containment changes from the earlier investigation were already present. I am therefore not claiming that a clean 1.1.1 installation necessarily reproduces this.
Observed problem
After upgrading to 1.1.1:
- All seven clusters were online.
- The overview correctly showed 37 VMs running and 22 stopped.
- Every cluster card showed
0% CPU,0% RAM, and0% Storage. - “Top Resources” simultaneously displayed valid, nonzero per-VM CPU and RAM values.
- The live-updates warning remained visible intermittently.
Authenticated /api/global/summary and /api/clusters/<id>/resources requests returned HTTP 200 with valid data, and pegaprox.service remained active.
Observed trigger
- Open All Clusters Overview after a transient SSE/proxy interruption.
- Polling takes over.
- One or more
/datacenter/statusrequests abort or time out while/resourcesand/global/summarystill succeed. - VM counts and Top Resources populate, but cluster CPU/RAM/storage render as zero.
Source finding
In the 1.1.1 tag, AllClustersOverview still derives the cluster cards exclusively from allMetrics and defaults missing values to zero. fetchClusters() populates allMetrics from each cluster’s /datacenter/status request.
The existing /api/global/summary endpoint is not wired into AllClustersOverview.
I also checked commit 1e33f09. It aligns CPU calculations and guest totals when metrics are available, but does not address the missing-data path.
Relevant 1.1.1 source:
Expected behavior
A missing or delayed telemetry response should never be displayed as an authoritative 0%.
The overview should either:
- render from a cached aggregate/per-cluster summary, or
- display “No data”/“Unavailable” for that metric until telemetry arrives.
Top Resources and cluster summary cards should be allowed to load independently.
Local mitigation tested
Our local repair:
- extended the cached global summary with per-cluster node, guest, CPU, RAM, storage, freshness, and availability fields;
- passed that summary into
AllClustersOverview; - used it for aggregate and per-cluster cards;
- treated unavailable telemetry as unavailable rather than zero;
- kept Top Resources on its independent resource feed;
- bounded the optional resource sweep, added single-flight protection and one retry;
- bumped the service-worker cache version.
Validation
After the repair:
- 7/7 clusters and 7/7 nodes
- 37 VMs running and 22 stopped
- 6% aggregate CPU
- 64% aggregate RAM
- 64% aggregate storage
- all seven cluster cards displayed nonzero current metrics
- no live-updates warning
- consecutive 30-second polling cycles returned HTTP 200
pegaprox.serviceremained active with zero restarts
Could you confirm whether you would like this remaining overview portion handled by reopening #784 or as a separate focused issue/PR? I can provide the exact diff if useful.
AI assistance disclosure: OpenAI Codex assisted with log analysis, source comparison, patch drafting, and validation. All changes were reviewed and tested by the operator.
Yeah, separate issue please — #784 was the reconnect storm and that part is done, what you are describing now is a different thing that just happened to show up in the same session.
Your read of it is right though, I checked: AllClustersOverview builds the cards straight off allMetrics and every value falls back to || 0, so a datacenter/status that times out renders as an authoritative 0% while Top Resources keeps working off a different source. That is exactly the split you saw. Feel free to paste what you already wrote into a fresh one, no need to redo the writeup.
We run on donations if you want to chip in: https://opencollective.com/pegaprox
Cheers, Marcus