Skip to content

Stabilize StarWars subscription tests against CI timing flake#9915

Merged
glen-84 merged 1 commit into
mainfrom
gai/stabilize-starwars-subscription-tests
Jun 15, 2026
Merged

Stabilize StarWars subscription tests against CI timing flake#9915
glen-84 merged 1 commit into
mainfrom
gai/stabilize-starwars-subscription-tests

Conversation

@glen-84

@glen-84 glen-84 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Three StarWarsCodeFirstTests subscription tests (SubscribeToReview_WithInlineFragment, SubscribeToReview_FragmentDefinition, SubscribeToReview_With_Variables) flaked under the xUnit v3 / Microsoft Testing Platform runner, producing a null snapshot instead of the expected onReview payload (example run).
  • They bounded the event wait with a 2000 ms CancellationTokenSource. Under CI thread-pool starvation the event isn't delivered in time, and SubscriptionEnumerator.MoveNextAsync swallows the resulting cancellation, so the read completes with no item and the snapshot mismatches null.
  • Switched all three to the pattern already used by SubscribeToReview: acquire the result enumerator before publishing, then MoveNextAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(30)) with Assert.True, so a genuine failure surfaces as a clear TimeoutException rather than a silent null. Also dropped the now-redundant explanatory comment so all four tests are uniform.

Test plan

  • dotnet test src/HotChocolate/Core/test/Execution.Tests/HotChocolate.Execution.Tests.csproj --filter-method "*StarWarsCodeFirstTests.SubscribeToReview*" → 12/12 passed across net8.0, net9.0, and net10.0.

Copilot AI review requested due to automatic review settings June 15, 2026 08:31

Copilot AI 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.

Pull request overview

This PR stabilizes the StarWars code-first subscription integration tests by removing a short, cancellation-based wait that could silently yield no subscription event under CI thread-pool starvation, and replacing it with a longer bounded wait that fails deterministically.

Changes:

  • Standardized the three affected subscription tests to acquire the subscription enumerator before publishing the mutation event.
  • Replaced the 2s CancellationTokenSource / await foreach pattern with MoveNextAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(30)) plus Assert.True(...) to surface failures as timeouts/assertions instead of null snapshots.
  • Removed a now-redundant comment to keep all four SubscribeToReview* tests uniform.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants