Repository navigation
fix: concurrent WebVNC viewers can fail to connect - #133226
Conversation
Retain each node viewer's inspected RFB connection through authentication so concurrent cloud and paired-node viewers do not double TigerVNC's pending connection attempts. Preserve buffered final frames and finish WebSocket closure before retiring desktop or portal control invocations.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 5:47 AM ET / 09:47 UTC. ClawSweeper reviewWhat this changesThe branch retains each node viewer’s inspected loopback RFB connection through Gateway authentication and waits for WebSocket closure after normal desktop or portal EOF. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review. The patch removes the source-proven second RFB connection per viewer and has focused integration coverage, but the supplied PR body still identifies native TigerVNC concurrency validation as outstanding; current-main comparison was also unavailable in this partial checkout. Priority: P1 Review scores
Verification
How this fits togetherWebVNC viewers attach through the Gateway to an enrolled node, which relays a loopback RFB desktop connection over a ticket-authenticated WebSocket. The changed node-side owner now preserves the initial RFB handshake connection and controls its end-of-stream behavior. flowchart LR
A[WebVNC viewer] --> B[Gateway observer]
B --> C[Ticketed node command]
C --> D[Loopback RFB handshake]
D --> E[Retained RFB stream]
E --> F[Gateway byte relay]
F --> A
Decision needed
Why: Synthetic transport tests establish the code path, but they cannot establish the server-specific acceptance-counter behavior described by the PR. Before merge
Agent review detailsSecurityNone. PR surfaceSource +132, Tests +466, Docs 0. Total +598 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single-connection owner design, attach a redacted exact-head TigerVNC concurrency trace, then refresh the review against current main before merge. Do we have a high-confidence way to reproduce the issue? Yes, from source: the merge-base first opened a disposable RFB probe and then the stream transport opened another socket, so three simultaneous viewers create six accepted connections. Native TigerVNC execution was not available in this review environment. Is this the best way to solve the issue? Yes, provisionally: retaining the socket at the RFB inspection owner removes the duplicate dial without changing Gateway ticket or loopback checks. Native-server evidence and a current-main refresh are still needed before a merge decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8cf4351e8fc1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…#133226) Retain each node viewer's inspected RFB connection through authentication so concurrent cloud and paired-node viewers do not double TigerVNC's pending connection attempts. Preserve buffered final frames and finish WebSocket closure before retiring desktop or portal control invocations.
What Problem This Solves
Fixes an issue where users opening several WebVNC viewers for a cloud session or paired node could receive a stream error even below the Gateway observer limit. The native TigerVNC server could blacklist the node's loopback address while other viewers remained connected.
Why This Change Was Made
Each viewer previously opened a disposable RFB security probe and then a second TCP connection for authentication. TigerVNC counts accepted attempts before authentication, so concurrent viewers doubled the pending attempts and could exhaust its existing protection threshold.
The node now inspects and retains one TCP connection per viewer. A bounded handshake adapter replays the inspected banner and security offer to the existing Gateway preauthentication flow and consumes only its identical version reply. Both owners share one version parser. Authentication, TLS pinning, ticket and placement checks, observer limits, and server blacklist protection remain unchanged.
The retained stream also owns cancellation and failed startup cleanup. Normal EOF drains buffered bytes, and the shared desktop/portal transport waits for the WebSocket close acknowledgement before completing its control-channel invocation, so the Gateway can receive the last frame before retiring the stream. Abort still closes immediately.
User Impact
Concurrent cloud and paired-node viewers no longer create extra unauthenticated probe connections. Desktop and portal streams preserve their final response on normal peer closure.
Named follow-up: Gateway-host status/readiness uses a separate standalone-probe contract. Repeated status checks without authentication can still accumulate TigerVNC attempt marks; this PR does not change that contract or remove the server's legitimate limit on simultaneous pending authentications.
Evidence
The original three-viewer reproduction, using real TCP/WebSocket transports and TigerVNC 1.15.0's accept/authentication counter semantics, produced five accepted connections, one blocked connection, and two authenticated viewers. The same scenario on the fix produces exactly three accepted connections, no blocked connections, and three authenticated viewers. The new paired-node and cloud-worker integration regressions also fail against the original command because it opens six connections for three viewers.
All 83 focused tests pass across the RFB probe/preauthentication, node desktop command, shared stream transport, portal command, and paired/cloud observe integration suites. Coverage includes RFB 3.3/3.7/3.8 and macOS 3.889, split/coalesced handshakes, changed-version refusal, cancellation, failed credentials/startup, a paused consumer retaining a final 32 KiB response, view-only filtering, three concurrent viewers, final-frame delivery before command completion, direct/proxied TLS portal and desktop EOF, successful finalization after paused EOF, and close acknowledgement when target write backpressure ends without a drain event. A real queued-write test holds an 8 MiB TCP write pending with a second wrapper write, sends FIN with a final response, and verifies both callbacks, every outgoing byte, the final response, and full stream completion; cancellation and pre-attach FIN variants also pass.
Independent P0–P2 reviews found shutdown edges around duplicate finalization, paused acknowledgement reads, native EOF leaving outer writable admission open, and competing native/wrapper finalizers with queued writes. Each was reproduced with a failing regression before repairing the stream lifecycle; the final complete-source P0–P2 review has no actionable findings.
Production LOC is +246/-114 (net +132); tests are +667/-201. The growth is the explicit owner for one retained socket and its buffered EOF lifecycle. It replaces the second connection, duplicate version parser, and separate flowing read buffer; there is no new configuration, dependency, retry, timeout increase, or compatibility path.
All selected repository guards passed in composed verification. The canonical core-test typecheck was rerun successfully in a fresh frozen install because its transitively imported UI Vite config could not resolve pako declarations in the shared local dependency layout. Source hashes and modes were verified unchanged after tests, and no dependency files changed.
Exact-head CI passed on the first attempt. The exact committed package also passed 8/8 compiled stress subprocesses covering 32 observer/auxiliary WebSocket and 36 worker authority/shutdown scenarios in 133.993 seconds, with no retries, failures, or stderr. This is supporting proof of the surrounding compiled owners; it does not exercise the outbound node TCP splice.
The exact committed package was exercised through the real cloud-session UI on Linux with TigerVNC 1.15.0, TLS pins, and CUA doctor checks passing. TigerVNC retained its default blacklist protection (enabled, threshold 5, timeout 10 seconds), with no overrides. The initial local disk guard rejected startup before any session or lease allocation; disposable test fixture/state was moved to a filesystem with sufficient headroom before retry. No package source or storage safety guard changed.
Native before/after trace, with addresses and session identifiers omitted:
7f1d2be9fde4All six original helper connections remained intact for 341.1 seconds without reconnecting, and the real WebVNC view still showed the counter at 3. Canonical idle reclaim then completed in 59.258 seconds: all six original connections closed with owner code 1012 after the reclaim RPC, all seven helper processes exited successfully, the placement was reclaimed, the environment was destroyed, and the provider independently reported the lease released. The actual UI disconnected. A fresh RFB frame immediately before reclaim also showed 3.
The passive helpers establish initial pixels and connection continuity; current pixels were separately checked in the actual UI. Read-only verifier precondition mistakes were corrected and preserved in the evidence, but no native viewer or CUA action was retried. This is exact PR-head package proof, not proof of every later main change or active Stop terminal persistence; combined-current-main Stop validation is a separate follow-up.
Review Follow-through
The latest ClawSweeper review found no actionable code or security findings. Its rank-up requests are addressed by the native before/after trace above and a direct current-main comparison: main
e42bb23a84933669c67173ed3b7640567b6f1ce9has no changes since the reviewed base in the affected desktop owner subtree, desktop/portal commands, shared node transport, or cloud-worker documentation; a merge simulation is clean. The PR head and exact-head CI remain unchanged.The automated stored-data warning on
rfb-preauth.tsis not applicable: the diff replaces an in-memory RFB version parser with the canonical parser and validates the negotiated wire version. It adds no serialized persistent state, schema, database, configuration, or migration contract.