Skip to content

fix(tests): filter telemetry fetch calls in DO/Hetzner mocks#3391

Closed
la14-1 wants to merge 1 commit intomainfrom
fix/flaky-test-telemetry-pollution
Closed

fix(tests): filter telemetry fetch calls in DO/Hetzner mocks#3391
la14-1 wants to merge 1 commit intomainfrom
fix/flaky-test-telemetry-pollution

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented May 5, 2026

Summary

  • Fixes 2 consistently flaky tests that failed in the full parallel suite but passed in isolation
  • Root cause: PostHog telemetry fetch() calls fired during async test execution, polluting callCount in mocks that captured all globalThis.fetch traffic
  • Fix: URL-filter mocks to only count calls to the relevant API domain (digitalocean/hetzner)

Tests fixed

  • doApi 401 OAuth recovery > attempts OAuth recovery on 401 before throwing
  • hetzner/createServer > cleans up orphaned primary IPs on resource_limit_exceeded and retries

Test plan

  • Full test suite passes: 2177 pass, 0 fail (verified 3 consecutive runs)
  • Lint passes

-- refactor/test-engineer

PostHog telemetry fires fetch calls during parallel test execution,
polluting callCount in tests that mock globalThis.fetch. Filter by URL
to only count calls to the relevant API domain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 6, 2026

Duplicate of #3379. Both PRs fix the same two test files (digitalocean-token.test.ts and hetzner-cov.test.ts) by switching from sequential callCount mocking to URL-based mock routing. #3379 was opened 4 days earlier and already has the duplicate-of-#3378 comment resolved (the earlier #3378 was closed).

Additionally, #3376 fixes the root cause (telemetry singleton leak in sendEvent()) and should land first — once it does, the telemetry fetch calls stop polluting other tests entirely.

Recommendation: This PR is superseded by #3379 (which covers the same test-level fix) + #3376 (which fixes the root cause). Only one of #3379/#3391/#3394 should be merged.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 7, 2026

Closing in favor of #3376 which fixes the root cause (telemetry singleton pollution) systemically. #3376 prevents the class of bug entirely by disabling telemetry in test preload and adding a runtime guard in sendEvent(), making per-test filtering unnecessary.

-- refactor/pr-maintainer

@la14-1 la14-1 closed this May 7, 2026
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.

2 participants