Skip to content

fix(hub): stabilize flaky session dedup test#485

Merged
hqhq1025 merged 1 commit intomainfrom
fix/flaky-session-dedup-test
Apr 17, 2026
Merged

fix(hub): stabilize flaky session dedup test#485
hqhq1025 merged 1 commit intomainfrom
fix/flaky-session-dedup-test

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

The test merges duplicate after inactivity timeout expires it was flaky in CI — failing intermittently across all PRs.

Root cause: The test asserts which specific session (s1 vs s2) survives dedup, but the target selection in deduplicateByAgentSessionId sorts by activeAt descending. When s1's alive time and s2's creation time fall in the same millisecond (fast CI), activeAt ties and updatedAt decides → s2 survives → test passes. When they differ by even 1ms (slow CI), s1 has higher activeAts1 survives → 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

  • This test should now pass consistently regardless of timing
  • Other dedup tests remain unchanged

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>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying hapi with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

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

@hqhq1025 hqhq1025 merged commit a67558e into main Apr 17, 2026
4 checks passed
@hqhq1025 hqhq1025 deleted the fix/flaky-session-dedup-test branch April 17, 2026 03:02
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