Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/terminal-input-waits-for-the-snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Maintenance
- The terminal input check waits for the snapshot before it asks for a liveness probe: on CI the
snapshot can follow the pane's first frames by a few milliseconds, and a wake before it probes
nothing.
5 changes: 5 additions & 0 deletions scripts/terminal-input-regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export async function checkTerminalInput(browser: Browser, origin: string, pane:
let holdPings = false;
const heldPings: string[] = [];
let toServer: ((raw: string) => void) | undefined;
// the snapshot names what the bridge answers, pings among it; it can follow input-ready by a few ms
let snapshotSent = false;
await page.routeWebSocket(/\/ws(?:\?|$)/, (socket) => {
if (refuseConnections) { void socket.close(); return; }
currentSocket = socket;
Expand All @@ -37,6 +39,7 @@ export async function checkTerminalInput(browser: Browser, origin: string, pane:
const frame = JSON.parse(String(raw));
if (delayReady && frame.type === "input-ready") ready = () => socket.send(raw);
else socket.send(raw);
if (frame.type === "snapshot") snapshotSent = true;
});
socket.onMessage((raw) => {
const frame = JSON.parse(String(raw));
Expand Down Expand Up @@ -80,6 +83,8 @@ export async function checkTerminalInput(browser: Browser, origin: string, pane:
// a wake then finds nothing to probe
await page.locator(".conn-live").waitFor();
await waiting.waitFor({ state: "hidden" });
// nor does a wake probe before the snapshot has said the bridge answers pings
await until(() => snapshotSent);
holdPings = true;
await page.evaluate(() => window.dispatchEvent(new Event("online")));
await until(() => heldPings.length > 0);
Expand Down
Loading