Skip to content

fix(server): clear auth cleanup intervals to prevent flaky test exits#5576

Open
garvitkaushik-123 wants to merge 1 commit into
adcontextprotocol:mainfrom
garvitkaushik-123:fix/flaky-cross-tenant-test-interval-cleanup
Open

fix(server): clear auth cleanup intervals to prevent flaky test exits#5576
garvitkaushik-123 wants to merge 1 commit into
adcontextprotocol:mainfrom
garvitkaushik-123:fix/flaky-cross-tenant-test-interval-cleanup

Conversation

@garvitkaushik-123

Copy link
Copy Markdown
Contributor

Summary

Fixes the flaky require-admin-cross-tenant.test.ts that fails under full-suite parallelism but passes in isolation (#5393).

Root cause: The three setInterval timers started by startBackgroundCleanup in auth.ts (session cache, DB refresh, ban cache) are never cleared. When vitest exits while an interval callback is still in-flight, the worker can produce a corrupted response on the affected test.

Fix:

  • startBackgroundCleanup now returns the timer handle instead of void
  • All three timer handles are captured at module scope
  • New stopAuthTimers() export calls clearInterval on all three
  • Test adds afterAll(() => stopAuthTimers()) for clean teardown

Non-breaking — adds one optional export to auth.ts, no protocol surface change.

Test plan

  • vitest run server/tests/unit/require-admin-cross-tenant.test.ts — 16/16 pass
  • vitest run --no-file-parallelism server/tests/ — full sequential suite to confirm the race is gone
  • tsc --noEmit — compiles clean

Closes #5393

The three `setInterval` timers in auth.ts (session cache, DB refresh,
ban cache) were never cleared. When vitest exits while an interval
callback is still in-flight, the worker can produce a corrupted response
and flake the `require-admin-cross-tenant` test.

Capture each timer handle from `startBackgroundCleanup` and export a
`stopAuthTimers()` helper so test teardown can clear them cleanly.

Closes adcontextprotocol#5393

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aao-ipr-bot

aao-ipr-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

IPR Policy Agreement Required

@garvitkaushik-123 — thanks for the contribution. Before this PR can be merged, the AgenticAdvertising.Org IPR Policy requires your agreement.

To agree, post a new comment on this PR with the exact phrase:

I have read the IPR Policy

Your signature is recorded once and covers all contributions to AAO repositories. See signatures/README.md for what gets recorded and why.

@aao-release-bot aao-release-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Argus review could not complete

The automated review encountered an issue (possibly reached max turns, timed out, or failed to post the final gh pr review). A human reviewer should take this PR.

View workflow run

This is an automated message from the Argus AI review workflow.

@garvitkaushik-123

Copy link
Copy Markdown
Contributor Author

I have read the IPR Policy

@aao-ipr-bot

aao-ipr-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

IPR Policy — signed

Thanks, @garvitkaushik-123. Your agreement to the IPR Policy is recorded at signatures/ipr-signatures.json and applies to all AAO repositories.

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.

Flaky: require-admin-cross-tenant.test.ts fails under full-suite parallelism, passes in isolation

1 participant