test(playground): exercise SSE reconnect Last-Event-ID replay#451
Open
MarioCadenas wants to merge 1 commit into
Open
test(playground): exercise SSE reconnect Last-Event-ID replay#451MarioCadenas wants to merge 1 commit into
MarioCadenas wants to merge 1 commit into
Conversation
The existing reconnect E2E tests only cover the happy path (mocked stream, all 5 messages delivered at once), so a Last-Event-ID replay regression in the StreamManager ring buffer could go undetected. This adds a recovery test that runs against the real server, drops the network mid-stream via context.setOffline, and asserts the client ends with all 5 messages and exactly one card per message (no gaps, no duplicates) — proving buffered events were replayed on reconnect. Co-authored-by: Isaac Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The existing reconnect E2E tests in
apps/dev-playground/tests/reconnect.spec.tsonly cover the happy path. They installsetupMockAPI, which fulfills/api/reconnect/streamwith a static SSE body delivering all 5 messages at once — the connection is never actually dropped. As a result, the real server reconnection path (StreamManager ring-buffer replay viaLast-Event-ID,packages/appkit/src/stream/stream-manager.ts) was never exercised end-to-end. That blind spot is exactly why a real reconnect regression could survive ~6 weeks: a broken replay would still pass every existing test.What
Adds one recovery test (kept alongside, not replacing, the happy-path tests) in a separate
describeblock so it runs against the real dev-playground server (no stream mock):/reconnect, waits until some (≥1, <5) messages have arrived.context.setOffline(true)thensetOffline(false), which aborts the in-flight SSE fetch and triggers the client's reconnect with aLast-Event-IDheader against the samestreamId.5), status never reachesError, and the rendered list contains exactly oneMessage k/5card for eachkin 1..5 — i.e. no gaps and no duplicates, which is what proves the server replayed the buffered events the client missed.Assertions use Playwright web-first /
expect.pollwith generous timeouts (no arbitrary sleeps beyond the brief offline window) to keep the SSE timing robust. The test is annotatedscenario: reconnect-replayfor triage.Verification
Ran locally against the real server (reproducing CI env:
APPKIT_E2E_TEST=true+ mock workspace vars), Playwright auto-starting the server:reconnect.spec.ts: 4 passed (new recovery test ~13s).--repeat-each=3: 3/3 passed, stable ~12.8s — no flakiness observed.StreamManager._attachToExistingStreamand confirmed the new test fails (stalls at 4 messages, never reaches 5), proving it genuinely catches a replay regression. Reverted afterwards.Biome clean; no new lint errors. The
playground-integration-testCI job will also execute this.This pull request and its description were written by Isaac.