Skip to content

Conversation

@thomhurst
Copy link
Owner

Summary

  • Bug 1 (PRIMARY): CreateFailedTestDetails called InitializeAttributesAsync() — the exact method that caused the original exception — re-triggering the failure inside the catch block. Made it synchronous with empty attributes, matching the safe TestBuilderPipeline pattern.
  • Bug 2: FailedExecutableTest in TestBuilder was missing State = TestState.Failed and Result, so failed tests didn't get the early-exit in TestCoordinator.ExecuteTestInternalAsync. Added both to match the TestBuilderPipeline version.
  • Bug 3: The 5-minute discovery timeout CTS in TestDiscoveryService.DiscoverTestsStreamAsync was created but the original cancellationToken was passed to BuildTestsStreamingAsync instead of cts.Token, so the timeout was never applied.

Closes #4715

Test plan

  • Verify TUnit.Engine compiles with no errors or warnings
  • Run existing engine tests to check for regressions
  • Verify tests with failing InitializeAsync now report as failed instead of hanging

🤖 Generated with Claude Code

…ssDataSource dependencies (#4715)

Three bugs combined to cause indefinite hangs when IAsyncDiscoveryInitializer.InitializeAsync() throws:

1. CreateFailedTestDetails called InitializeAttributesAsync — the exact method that caused the original exception — re-triggering the failure inside the catch block. Made it synchronous with empty attributes matching the safe TestBuilderPipeline pattern.

2. FailedExecutableTest in TestBuilder was missing State=Failed and Result, so failed tests didn't get the early-exit in TestCoordinator.ExecuteTestInternalAsync.

3. The 5-minute discovery timeout CTS was created but the original cancellationToken was passed instead of cts.Token, so the timeout was never applied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Summary

This PR fixes three critical bugs that could cause test hangs when InitializeAsync() throws exceptions:

  1. Bug 1: CreateFailedTestDetails no longer calls InitializeAttributesAsync(), preventing recursive exception triggering in error handlers
  2. Bug 2: FailedExecutableTest now properly sets State and Result properties for early exit paths
  3. Bug 3: Discovery timeout token (cts.Token) now correctly applied instead of being ignored

All changes align with existing patterns in TestBuilderPipeline and comply with CLAUDE.md requirements for performance, reliability, and AOT compatibility.

@thomhurst thomhurst enabled auto-merge (squash) February 10, 2026 13:34
@thomhurst thomhurst merged commit 0949446 into main Feb 10, 2026
12 of 13 checks passed
@thomhurst thomhurst deleted the fix/init-async-hang-4715 branch February 10, 2026 14:06
This was referenced Feb 10, 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.

[Bug]: Tests hang indefinitely when InitializeAsync throws exception

1 participant