From 8f44b0808c0b87da706a2f23d64fda86ed326bd2 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Fri, 18 Sep 2026 13:00:21 -0500 Subject: [PATCH] refactor(streaming): recover a missed launch-ready off the stamp alone The status poll carries the claim's stamp once the 202 lands, so it can only report this tab's own session and the container it echoed back had nothing left to check. --- backend/endpoints/responses/streaming.py | 3 --- backend/endpoints/streaming.py | 1 - backend/tests/endpoints/test_streaming.py | 2 -- .../models/SessionStatusSchema.ts | 1 - frontend/src/v2/views/Player/Stream.test.ts | 23 ++++++++++++------- frontend/src/v2/views/Player/Stream.vue | 5 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/backend/endpoints/responses/streaming.py b/backend/endpoints/responses/streaming.py index 2f9095fa6..72ae8f8f5 100644 --- a/backend/endpoints/responses/streaming.py +++ b/backend/endpoints/responses/streaming.py @@ -66,9 +66,6 @@ class SessionStatusSchema(BaseModel): host: str | None = None """The room URL of a launched session, for a tab that missed launch-ready, reported by the status poll only and left None by a heartbeat.""" - container: str | None = None - """The container the session was found on, so a tab recovering a missed - launch-ready enters only the session on the container it claimed.""" termination: SessionTerminationSchema | None = None diff --git a/backend/endpoints/streaming.py b/backend/endpoints/streaming.py index 823b6e634..e64b0141a 100644 --- a/backend/endpoints/streaming.py +++ b/backend/endpoints/streaming.py @@ -226,7 +226,6 @@ async def _session_status( # The room the launch answered with, so a tab that missed the # launch-ready push can enter the stream off a poll. "host": session.get("host"), - "container": container.key, } # An activate that has not returned yet leaves no launched_at behind. # Gating the broker round trip on it keeps this route pure Redis for diff --git a/backend/tests/endpoints/test_streaming.py b/backend/tests/endpoints/test_streaming.py index 740bfc9b8..b1a52b7c1 100644 --- a/backend/tests/endpoints/test_streaming.py +++ b/backend/tests/endpoints/test_streaming.py @@ -2920,7 +2920,6 @@ def test_status_reports_active_for_owner(client, access_token, rom: Rom): "extraction_phase": None, "termination": None, "host": container["host"], - "container": _key_of(container), } @@ -2936,7 +2935,6 @@ def test_status_carries_the_room_the_launch_answered_with(client, access_token): ) assert r.status_code == 200 assert r.json()["host"].endswith("/room/x") - assert r.json()["container"] == _key_of(container) def test_a_desktop_launch_is_stamped_without_a_room(client, access_token): diff --git a/frontend/src/__generated__/models/SessionStatusSchema.ts b/frontend/src/__generated__/models/SessionStatusSchema.ts index 8c5196d31..5c78470d7 100644 --- a/frontend/src/__generated__/models/SessionStatusSchema.ts +++ b/frontend/src/__generated__/models/SessionStatusSchema.ts @@ -8,7 +8,6 @@ export type SessionStatusSchema = { platform: string; extraction_phase?: (string | null); host?: (string | null); - container?: (string | null); termination?: (SessionTerminationSchema | null); }; diff --git a/frontend/src/v2/views/Player/Stream.test.ts b/frontend/src/v2/views/Player/Stream.test.ts index 20825db0a..12fd69913 100644 --- a/frontend/src/v2/views/Player/Stream.test.ts +++ b/frontend/src/v2/views/Player/Stream.test.ts @@ -619,7 +619,6 @@ describe("Stream launch recovery", () => { status: "active", platform: "gba", host: "http://webstation-dev:8080/room/x", - container: CLAIM.container, }); await pollStatus(); @@ -650,22 +649,31 @@ describe("Stream launch recovery", () => { wrapper.unmount(); }); - it("keeps waiting when the poll finds a game on another container", async () => { - // The unnamed poll reports any session the player holds on the platform, - // which can be another tab's. + it("keeps waiting when the poll answers before the claim does", async () => { + // Without the 202's stamp the poll reports any session the player holds on + // the platform, which can be another tab's. + let claimed = (_: typeof CLAIM) => {}; + mocks.claimSession.mockReturnValue( + new Promise((resolve) => { + claimed = resolve; + }), + ); const wrapper = await launch({ picker: false }); - await vmOf(wrapper).onPlay(); + const playing = vmOf(wrapper).onPlay(); + await flushPromises(); mocks.fetchSessionStatus.mockResolvedValue({ status: "active", platform: "gba", - host: "http://webstation-dev-2:8080/room/y", - container: "WEBSTATION-DEV-2", + host: "http://webstation-dev:8080/room/y", }); await pollStatus(); + expect(mocks.fetchSessionStatus).toHaveBeenCalledWith("gba", undefined); expect(vmOf(wrapper).playerState).toBe("loading"); expect(vmOf(wrapper).containerHost).toBe(""); + claimed(CLAIM); + await playing; wrapper.unmount(); }); @@ -676,7 +684,6 @@ describe("Stream launch recovery", () => { status: "active", platform: "gba", host: null, - container: CLAIM.container, }); await pollStatus(); diff --git a/frontend/src/v2/views/Player/Stream.vue b/frontend/src/v2/views/Player/Stream.vue index c915020f1..9c04b96e4 100644 --- a/frontend/src/v2/views/Player/Stream.vue +++ b/frontend/src/v2/views/Player/Stream.vue @@ -566,9 +566,8 @@ async function handleSessionStatus( // running session; the room the poll reports is its way back in. async function enterRunningSession(status: SessionStatus): Promise { if (playerState.value !== "loading" || !status.host) return; - // The poll names no container, so it can answer with another tab's session. - if (!claimedContainer.value || status.container !== claimedContainer.value) - return; + // An unstamped poll, sent before the 202, can answer with another tab's. + if (!claimedAt.value) return; launchPhase.value = null; containerHost.value = status.host; playerState.value = "playing";