Skip to content

feat(browser): replace fenced tunnel generations - #14507

Closed
Jinwoo-H wants to merge 1 commit into
sta-4150-browser-host-memory-ledgerfrom
sta-4150-browser-tunnel-reconnect
Closed

Jinwoo-H wants to merge 1 commit into
sta-4150-browser-host-memory-ledgerfrom
sta-4150-browser-tunnel-reconnect

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​361 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​425 $\color{#cf222e}{\Huge{\mathbf{−}}}$​181 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​244

Summary

  • keep one main-owned loopback SOCKS address stable and fail closed while its paired-runtime transport is offline or reconnecting
  • require each replacement transport to advance the server-owned tunnel generation, ignore superseded callbacks, and propagate client protocol failure to route ownership
  • recycle a bounded stream-ID ledger only by replacing the tunnel generation and closing active streams from the retired generation

Causal evidence

On parent a089829521, the deterministic oracle could not distinguish stream-ID exhaustion, transport loss destroyed the local listener with ECONNREFUSED, a second CONNECT opened no replacement transport, and generation 8 could be replayed after becoming ready and closing before the awaiting continuation resumed. The initial candidate also reproduced a dead-client wedge: invalid current-generation input closed the tunnel client without retiring its owning transport, so reconnect() treated it as live.

The reviewed candidate keeps the exact listener address across generation 7 → 8, rejects CONNECT before and during replacement, fences every observed generation synchronously, ignores late callbacks by exact transport identity, reports tunnel closure upward exactly once, and rolls an injected one-ID budget from [generation 7, stream 1] to [generation 8, stream 1].

Compatibility and activation

This is an inert STA-4150 layer stacked on #14504. Reconnect retains the existing network.browserTunnel v1 lease/execution-host payload and capability pair; it adds no exchanged field or opcode. Production still advertises neither capability and registers neither browser-host method, so old clients, unavailable preferred placement, and current server/offscreen browsing are unchanged. It does not depend on or duplicate merged Stage 0 PR #14402.

Still blocked before activation: Node stream-internal aggregate accounting; strict cross-route fairness and slow-link soak proof; relay/SSH/WSL execution-host adapters; browserless/headless behavior; SOCKS process trust/isolation; real old/new peer journeys; Electron partition proxy/no-fallback and exact WebContents lifecycle proof; Linux and physical Windows evidence.

Validation

  • latest origin/main 41ba29d; exact range-diff after rebase
  • 16 focused files / 131 tests
  • full runtime RPC suite / 1,349 passed, 1 skipped
  • full typecheck
  • native and type-aware code-quality audits
  • reliability manifest and max-lines ratchet
  • git diff check
  • two fresh read-only correctness/security/performance reviews; one P2 dead-client reconnect wedge fixed and re-reviewed

Linear: https://linear.app/stably/issue/STA-4150/refactor-remote-browser-to-client-hosted-electron-webviews

@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from 9889adf to 086382a Compare August 14, 2026 10:18
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from 086382a to 771da4f Compare August 14, 2026 20:02
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from 771da4f to 80e9810 Compare August 14, 2026 20:14
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch 3 times, most recently from d074737 to e644847 Compare August 15, 2026 00:44
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from e644847 to 72dda5e Compare August 15, 2026 00:57
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from 72dda5e to 7a9dbb1 Compare August 15, 2026 02:57
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch from 7a9dbb1 to 1201a01 Compare August 15, 2026 03:24
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch 2 times, most recently from 4f7a5eb to 9ae74c4 Compare August 15, 2026 10:24
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-browser-tunnel-reconnect branch 2 times, most recently from 2f34ba3 to ee135b9 Compare August 15, 2026 12:30
@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Closing because current main (a93e31a9339) already implements this stable-listener/generation-replacement stage.

The route and extracted paired-runtime-browser-network-transport.ts retain the listener while offline, reject CONNECT without a live tunnel, accept only increasing generations, record readiness synchronously, and ignore superseded transport callbacks. Client protocol closure still notifies the transport owner; bounded stream-ID exhaustion replaces the generation before recycling an ID. Reconnect still sends the existing native v1 identity/execution-host payload and capability pair.

The current client/route tests retain all introduced oracles: bounded ID non-reuse, offline and reconnecting refusal on the same address, unchanged payload, stale callbacks, protocol-failure recovery, non-increasing generation rejection, ready-before-await fencing, and generation-before-ID recycling. Main additionally runs bounded automatic transport recovery. The earlier manual-reconnect intermediate stage has no independent work left to merge.

@OrcaWin OrcaWin closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants