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.
This commit is contained in:
Zach Clendenen
2026-09-18 13:00:21 -05:00
parent 65ea8da612
commit 8f44b0808c
6 changed files with 17 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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):

View File

@@ -8,7 +8,6 @@ export type SessionStatusSchema = {
platform: string;
extraction_phase?: (string | null);
host?: (string | null);
container?: (string | null);
termination?: (SessionTerminationSchema | null);
};

View File

@@ -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<typeof CLAIM>((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();

View File

@@ -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<void> {
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";