Skip to content

test: wait for the mobile session start in Ctor_AutoSessionTrackingEnabled_StartsSession - #5939

Merged
jamescrosswell merged 2 commits into
mainfrom
test/hub-autosession-tracking-race
Nov 16, 2026
Merged

jamescrosswell merged 2 commits into
mainfrom
test/hub-autosession-tracking-race

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Ctor_AutoSessionTrackingEnabled_StartsSession now waits for the initial session instead of asserting right after creating the hub. On iOS and Android, #5863 made the app lifecycle tracker start the session on the main thread, so the old assertion raced it. It failed the first pass in about 18% of iOS and 9% of Android device-test jobs. On desktop the session still starts inside the constructor, so the wait returns immediately.

I kept the test on mobile because it's the only one that runs the trackers' real Start(), so it still fails if mobile sessions stop starting. The test also disposes the hub now, so the tracker's observers don't outlive it.

Because the hub test now accepts a later start, a new AutoSessionTrackingIntegrationTests case checks the desktop path: without a lifecycle tracker, the integration starts the session during Init.

On an iOS simulator, delaying the main-thread start by 300 ms made the old assertion fail every time while the new test passed, and removing the start made the new test fail. On desktop, removing hub.StartSession() from the integration still fails it.

Closes #5938

#skip-changelog

On iOS and Android, AutoSessionTrackingIntegration leaves the session start to the app lifecycle
tracker, which runs it on the main thread (#5863). Ctor_AutoSessionTrackingEnabled_StartsSession
asserted right after creating the hub, so it failed whenever the main thread hadn't run the start yet.

The test now waits up to 5 seconds for the initial session, then asserts as before. It also disposes
the hub, so the tracker's observers don't outlive the test.

Fixes #5938

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.44%. Comparing base (b9a48d2) to head (023f6fd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5939   +/-   ##
=======================================
  Coverage   77.43%   77.44%           
=======================================
  Files         546      546           
  Lines       20053    20053           
  Branches     3962     3962           
=======================================
+ Hits        15529    15531    +2     
+ Misses       3659     3658    -1     
+ Partials      865      864    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ric-oliv
ric-oliv marked this pull request as ready for review November 16, 2026 08:35
@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 16, 2026
Without an app lifecycle to follow, AutoSessionTrackingIntegration starts
the session during Init. The hub test now waits for the mobile start, so
this test is what fails if that start moves off the init path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Nov 16, 2026
@jamescrosswell
jamescrosswell merged commit 8cb5951 into main Nov 16, 2026
56 checks passed
@jamescrosswell
jamescrosswell deleted the test/hub-autosession-tracking-race branch November 16, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HubTests.Ctor_AutoSessionTrackingEnabled_StartsSession is flaky in the device tests

2 participants