Skip to content

Fix Cypress crossfade/gapless failures: keep playback_session in the earliest event batch - #699

Merged
osmestad merged 1 commit into
mainfrom
fix/cypress-playback-session-batching
Aug 11, 2026
Merged

Fix Cypress crossfade/gapless failures: keep playback_session in the earliest event batch#699
osmestad merged 1 commit into
mainfrom
fix/cypress-playback-session-batching

Conversation

@osmestad

Copy link
Copy Markdown
Contributor

Why

After #697 merged, the Cypress case-crossfade.cy.ts and case-gapless.cy.ts specs started failing on every open PR (expected 2 playback_session events, got 1). The specs never ran on #697 itself because it was stacked on the #696 branch and the Cypress workflow only triggers for PRs targeting main.

Root cause: the event sender dispatches at most 10 events per request (SQS batch limit), and the two specs asserted on the first intercepted batch only. A crossfade/gapless run produces enough events that the second track's playback_session sat exactly at the 10-event batch boundary. The event enqueue-timing changes in #697 (serialized reducers, actual-start reporting) shifted the order so it fell into the second batch — which the specs never looked at.

What

  • BasePlayer.eventTrackingStreamingEnded now enqueues playback_session before the session's own playback_statistics/streaming_session_end events, so the consumption-relevant play_log event is never bumped to a later batch by its own session's metrics events.
  • The crossfade and gapless specs now aggregate events across all intercepted event requests (retrying until a later batch arrives if needed) instead of asserting on the first request only, and include the seen event names in the assertion message for easier diagnosis.

Verified

  • pnpm --dir packages/player typecheck and lint:ci pass locally.
  • Cypress runs in CI on this PR (could not be run locally — requires the CI test-user secret).

Made with Cursor

The event sender dispatches at most 10 events per request. The crossfade
and gapless e2e specs asserted on the first intercepted batch only, and
the second track's playback_session event sat exactly at the batch
boundary. The event timing changes in #697 shifted the enqueue order so
it fell into the second batch, failing the specs on every PR.

- Enqueue playback_session before the session's own playback_statistics
  and streaming_session_end events so the consumption-relevant event is
  never bumped to a later batch by its own session's metrics events.
- Make the crossfade/gapless specs aggregate events across all
  intercepted batches (retrying until the second batch arrives) and
  include the seen event names in the assertion message.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Cypress flakiness/regressions in the crossfade and gapless play-log specs by ensuring playback_session events are dispatched early enough to land in the earliest event batch, and by updating the specs to assert across all intercepted event batches (not just the first request).

Changes:

  • Reordered end-of-session event sending so playback_session is committed before the session’s streaming-metrics end events.
  • Updated crossfade/gapless Cypress specs to aggregate events across all intercepted event requests and include better assertion diagnostics.
  • Documented the behavioral change in the player changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/player/src/player/basePlayer.ts Ensures playback_session is committed before auxiliary streaming-metrics events on session end to stabilize earliest-batch ordering.
packages/player/cypress/e2e/play-log/case-gapless.cy.ts Aggregates events across all intercepted requests and retries until both playback_session events are observed.
packages/player/cypress/e2e/play-log/case-crossfade.cy.ts Same aggregation/retry strategy as gapless to avoid asserting on only the first batch.
packages/player/CHANGELOG.md Notes the updated enqueue/dispatch ordering for playback_session vs. streaming-metrics end events.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@osmestad
osmestad merged commit 3139c10 into main Aug 11, 2026
8 checks passed
@osmestad
osmestad deleted the fix/cypress-playback-session-batching branch August 11, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants