Skip to content

Bug 2000191: fix intermittent test failure caused by race condition.#243

Open
pollym wants to merge 1 commit intomozilla-firefox:autolandfrom
pollym:fix-race-condition-in-synced-tabs-storage-test
Open

Bug 2000191: fix intermittent test failure caused by race condition.#243
pollym wants to merge 1 commit intomozilla-firefox:autolandfrom
pollym:fix-race-condition-in-synced-tabs-storage-test

Conversation

@pollym
Copy link
Copy Markdown
Contributor

@pollym pollym commented May 5, 2026

Root cause: Bug 1879332 changed TabSessionState.isActive() to use maxOf(lastAccess, createdAt).
Since createTab() defaulted createdAt = System.currentTimeMillis(), newly created test tabs have createdAt ≈ now.
With maxActiveTime = 0, the check now - createdAt <= 0 only returns false when at least 1ms has elapsed, making the result dependent on test execution speed.

Fix: Pass createdAt = lastAccess to all createTab() calls in tests that use maxActiveTime = 0 and expect inactive = true.
Since lastAccess values like 123L are epoch-old timestamps, now - maxOf(123L, 123L) is always a large positive number, so isActive(0) deterministically returns false regardless of when the test runs.

Root cause: Bug 1879332 changed `TabSessionState.isActive()` to use `maxOf(lastAccess, createdAt)`. Since createTab() defaulted `createdAt = System.currentTimeMillis()`, newly created test tabs have createdAt ≈ now. With `maxActiveTime = 0`, the check `now - createdAt <= 0` only returns false when at least 1ms has elapsed, making the result dependent on test execution speed.
Fix: Pass `createdAt = lastAccess` to all `createTab()` calls in tests that use `maxActiveTime = 0` and expect `inactive = true`. Since lastAccess values like 123L are epoch-old timestamps, `now - maxOf(123L, 123L)` is always a large positive number, so `isActive(0)` deterministically returns `false` regardless of when the test runs.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

View this pull request in Lando to land it once approved.

@pollym
Copy link
Copy Markdown
Contributor Author

pollym commented May 5, 2026

try is here

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.

1 participant