fix(hub): stabilize flaky session dedup test#485
Merged
Conversation
The test 'merges duplicate after inactivity timeout expires it' was flaky because it asserted which specific session survives the dedup, but the target selection depends on activeAt ordering which varies by millisecond timing in CI. When s1's alive time and s2's creation time fall in the same millisecond, s2 survives (test passes); when they differ, s1 survives (test fails). Fix by asserting that exactly one session remains after dedup, without depending on which one is the merge target. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
Deploying hapi with
|
| Latest commit: |
fdecb8b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7069fbcb.hapi-bqd.pages.dev |
| Branch Preview URL: | https://fix-flaky-session-dedup-test.hapi-bqd.pages.dev |
There was a problem hiding this comment.
Findings
- No actionable issues found in the added/modified lines.
Summary
Review mode: initial
No issues found in the latest diff. Residual risk/testing gap: static review only; tests were not executed in this review pass.
Testing
- Not run (security: diff review only)
HAPI Bot
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.
Summary
The test
merges duplicate after inactivity timeout expires itwas flaky in CI — failing intermittently across all PRs.Root cause: The test asserts which specific session (
s1vss2) survives dedup, but the target selection indeduplicateByAgentSessionIdsorts byactiveAtdescending. Whens1's alive time ands2's creation time fall in the same millisecond (fast CI),activeAtties andupdatedAtdecides →s2survives → test passes. When they differ by even 1ms (slow CI),s1has higheractiveAt→s1survives → test fails.Fix: Assert that exactly one session remains after dedup, without depending on which one is the merge target. The test's purpose is to verify that dedup occurs after inactivity timeout — not which session becomes the target.
Test plan