From 0a2c9d945e95729773734888609f86fb4ed74286 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Thu, 12 Nov 2026 20:39:20 -0300 Subject: [PATCH 1/2] Say what a refusal does to Remote-SSH, and the lane asserts it Closing the remote after Spinbox's message does not stop Remote-SSH: VS Code calls its resolver once the activation returns, and holding the activation instead holds the window's unload forever. connect.ts says so, and that spin's ssh-proxy now ends that ssh at once on a refusal spin code marked as told (spin-stack/spin#1182). The unenrolled case asserts that sequence: Spinbox's message first, with Remote-SSH waiting behind it; then Remote-SSH's own error within 5 s of its resolver, with no askpass request and no banner timeout in its log; and the window local within 5 s of the message closing. Co-Authored-By: Claude Opus 5.5 --- src/remote/connect.ts | 6 +++++- test/remote-ssh/run.mjs | 28 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/remote/connect.ts b/src/remote/connect.ts index a6bc3af..44406ce 100644 --- a/src/remote/connect.ts +++ b/src/remote/connect.ts @@ -9,7 +9,11 @@ import type { Trace } from "../telemetry" // extension does (coder/vscode-coder docs/ARCHITECTURE.md): `spin code --start` starts it, // attaches this VS Code's server, writes the ssh config, and connects once through it - which runs // `spin ssh-prepare` and its launch-claim check - so a refusal is the CLI's error, with its action, -// here. A failure closes the remote, so Remote-SSH does not go on to fail its own way. +// here, first. A failure then closes the remote. That does not stop Remote-SSH: VS Code calls its +// resolver once this activation returns, and holding the activation instead holds the window's +// unload on that resolution forever. So Remote-SSH still connects once, and says briefly that it +// could not: spin code keeps its refusal marked as told, and the ssh-proxy of Remote-SSH's ssh +// ends at once on the same refusal rather than ask again (spin's toldAlready). export type ConnectCli = Pick diff --git a/test/remote-ssh/run.mjs b/test/remote-ssh/run.mjs index ee48c9b..289783c 100644 --- a/test/remote-ssh/run.mjs +++ b/test/remote-ssh/run.mjs @@ -10,8 +10,9 @@ // - stopped: the same, with the workspace started by that `spin code --start`, and no error of // Remote-SSH's; // - unenrolled: with a key the account does not have, Spinbox says key_not_enrolled (whose -// action is Add Key), Remote-SSH never resolves, and once the message is closed - READ_MS -// after it is said, as a person reads it - the window leaves the remote. +// action is Add Key) and Remote-SSH waits while it is up. Once it is closed - READ_MS after it +// is said, as a person reads it - Remote-SSH resolves once, spin ends its ssh at once (no +// askpass, no ConnectTimeout), its error follows within seconds, and the window is local. // // SPIN_STACK names the spin checkout whose stack is up: its bin/spin, and the fixture user's home // hack/e2estack keeps. Each case runs in bubblewrap with a home of its own bound over $HOME, since @@ -53,6 +54,8 @@ const only = process.env.CASES?.split(",") const WAIT_MS = 360_000 // How long the unenrolled case leaves Spinbox's message up before closing it. const READ_MS = Number(process.env.READ_MS ?? 30_000) +// What "at once" is for a refused Remote-SSH: well under its 15 s ConnectTimeout. +const QUICK_MS = 5_000 const say = (line) => console.log(`==> ${line}`) @@ -348,13 +351,24 @@ const cases = { o.resolving === undefined || o.resolvingMs >= dismissed?.t, [o.end, `message closed at ${dismissed?.t}`, `Remote-SSH: ${o.resolving}`], ) - check("unenrolled: Remote-SSH never resolved", o.resolving === undefined, o.resolving) - const errors = errorsOf(s) - check("unenrolled: Remote-SSH said no error", errors.length === 0, errors.slice(0, 5)) + // Then Remote-SSH connects once anyway (src/remote/connect.ts), and is ended at once by spin's + // ssh-proxy: no askpass box, no wait for its ConnectTimeout. + const gaveUp = errorsOf(s)[0] + const gaveUpMs = gaveUp === undefined ? undefined : timeOf(gaveUp, s.started) + check( + `unenrolled: Remote-SSH's error came within ${QUICK_MS / 1000} s of its resolver`, + o.resolvingMs !== undefined && gaveUpMs !== undefined && gaveUpMs - o.resolvingMs <= QUICK_MS, + [o.resolving, gaveUp], + ) + const asked = s.remoteSSH.filter((l) => /askpass request|banner exchange/i.test(l)) + check("unenrolled: Remote-SSH's ssh asked nothing and waited for nothing", asked.length === 0, [ + ...asked.slice(0, 3), + s.remoteSSH.find((l) => l.includes("as the editor already said")), + ]) const left = s.probe.filter((e) => e.event === "activate").at(-1) check( - "unenrolled: the window left the remote within 5 s of the message closing", - left?.remoteName === null && dismissed !== undefined && left.t - dismissed.t <= 5_000, + `unenrolled: the window left the remote within ${QUICK_MS / 1000} s of the message closing`, + left?.remoteName === null && dismissed !== undefined && left.t - dismissed.t <= QUICK_MS, `message closed at ${dismissed?.t}, window local at ${left?.t} (remoteName=${left?.remoteName})`, ) }, From 5f8e508a89a665254ab7d89d4898bc84e09baace Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Thu, 12 Nov 2026 21:17:43 -0300 Subject: [PATCH 2/2] test: the remote-ssh lane's clock and the window's own restart The spin wrapper stamped calls with uutils' date +%s%3N, which on a loaded host mixed one instant's seconds with another's milliseconds and wrote an end before its start; it reads bash's EPOCHREALTIME instead. A refused Remote-SSH's speed is measured from its ssh, after Remote-SSH started its local server, and the window from the renderer starting again, not the probe's later activation in it. Co-Authored-By: Claude Opus 5.5 --- test/remote-ssh/run.mjs | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/test/remote-ssh/run.mjs b/test/remote-ssh/run.mjs index 289783c..8dc5c76 100644 --- a/test/remote-ssh/run.mjs +++ b/test/remote-ssh/run.mjs @@ -54,8 +54,11 @@ const only = process.env.CASES?.split(",") const WAIT_MS = 360_000 // How long the unenrolled case leaves Spinbox's message up before closing it. const READ_MS = Number(process.env.READ_MS ?? 30_000) -// What "at once" is for a refused Remote-SSH: well under its 15 s ConnectTimeout. +// What "at once" is for a refused Remote-SSH's ssh: well under its 15 s ConnectTimeout. const QUICK_MS = 5_000 +// How long the window may take to start again, local: Remote-SSH's local server and its ssh, then +// the unload - 10 s on a host at load 22. Waiting out the ConnectTimeout alone took 17 s. +const LEAVE_MS = 15_000 const say = (line) => console.log(`==> ${line}`) @@ -157,13 +160,15 @@ async function openCase(name, workspace, { enrolled, until }) { // An empty system ssh config: in bubblewrap's namespace root's files are nobody's, which ssh // refuses to read. writeFileSync(join(dir, "ssh_config"), "") - // Each spin the extension runs, said with when it started and ended, around the real one. + // Each spin the extension runs, said with when it started and ended, around the real one. The + // time is bash's own clock read, in ms: uutils' `date +%s%3N` mixed one instant's seconds with + // another's milliseconds on a loaded host, and wrote an end before its start. const calls = join(dir, "spin-calls.log") const wrapper = join(dir, "spin") - const stamp = (what) => `echo "$(date +%s%3N) ${what} $*" >> ${calls}` + const stamp = (what) => `t=\${EPOCHREALTIME/./}; echo "\${t%???} ${what} $*" >> ${calls}` writeFileSync( wrapper, - `#!/bin/sh\n${stamp("start")}\n${spin} "$@"\nrc=$?\n${stamp("end $rc")}\nexit $rc\n`, + `#!/bin/bash\n${stamp("start")}\n${spin} "$@"\nrc=$?\n${stamp("end $rc")}\nexit $rc\n`, ) chmodSync(wrapper, 0o755) mkdirSync(join(userData, "User"), { recursive: true }) @@ -231,6 +236,7 @@ async function openCase(name, workspace, { enrolled, until }) { spinbox: logOf(userData, "Spinbox.log"), remoteSSH: logOf(userData, "Remote - SSH.log"), exthost: logOf(userData, "exthost.log"), + renderer: logOf(userData, "renderer.log"), }) let s = seen() const end = Date.now() + WAIT_MS @@ -353,23 +359,37 @@ const cases = { ) // Then Remote-SSH connects once anyway (src/remote/connect.ts), and is ended at once by spin's // ssh-proxy: no askpass box, no wait for its ConnectTimeout. + // From Remote-SSH's ssh: what comes before it is Remote-SSH starting its local server. + const spawned = s.remoteSSH.find((l) => /Spawned ssh, pid=/.test(l)) + const spawnedMs = spawned === undefined ? undefined : timeOf(spawned, s.started) const gaveUp = errorsOf(s)[0] const gaveUpMs = gaveUp === undefined ? undefined : timeOf(gaveUp, s.started) check( - `unenrolled: Remote-SSH's error came within ${QUICK_MS / 1000} s of its resolver`, - o.resolvingMs !== undefined && gaveUpMs !== undefined && gaveUpMs - o.resolvingMs <= QUICK_MS, - [o.resolving, gaveUp], + `unenrolled: Remote-SSH's error came within ${QUICK_MS / 1000} s of its ssh`, + spawnedMs !== undefined && gaveUpMs !== undefined && gaveUpMs - spawnedMs <= QUICK_MS, + [o.resolving, spawned, gaveUp], ) const asked = s.remoteSSH.filter((l) => /askpass request|banner exchange/i.test(l)) check("unenrolled: Remote-SSH's ssh asked nothing and waited for nothing", asked.length === 0, [ ...asked.slice(0, 3), s.remoteSSH.find((l) => l.includes("as the editor already said")), ]) + // The window that replaces the remote one starts when the renderer starts up again; the + // probe's activation in it says it is local, and comes when its extension host does, later. + const reopened = s.renderer.filter((l) => l.includes("[lifecycle] starting up"))[1] + const reopenedMs = reopened === undefined ? undefined : Date.parse(reopened.slice(0, 23)) const left = s.probe.filter((e) => e.event === "activate").at(-1) check( - `unenrolled: the window left the remote within ${QUICK_MS / 1000} s of the message closing`, - left?.remoteName === null && dismissed !== undefined && left.t - dismissed.t <= QUICK_MS, - `message closed at ${dismissed?.t}, window local at ${left?.t} (remoteName=${left?.remoteName})`, + `unenrolled: the window left the remote within ${LEAVE_MS / 1000} s of the message closing`, + left?.remoteName === null && + dismissed !== undefined && + reopenedMs !== undefined && + reopenedMs - dismissed.t <= LEAVE_MS, + [ + `message closed at ${new Date(dismissed?.t).toISOString()}`, + `window started again: ${reopened}`, + `probe in it: remoteName=${left?.remoteName}`, + ], ) }, }