Conversation
…tializes then throws (#4715) When InitializeAsync() starts resources (e.g. ports, background processes) then throws, TUnit was removing the failed entry from its initialization caches to allow retry. The retry calls InitializeAsync() again on the same partially-initialized shared object, which hangs because the first resources still hold ports/processes. - Stop removing failed/cancelled entries from ObjectInitializer and ObjectLifecycleService caches so the faulted task is returned immediately to subsequent callers - Fix fast-path in ObjectLifecycleService to also check IsCanceled so cancelled initializations don't silently return uninitialized objects - Add 5-minute discovery timeout to the filter execution path matching the existing streaming path timeout - Add engine test for attribute-based property injection failure scenario Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. The PR correctly addresses issue #4715 by keeping failed/cancelled initialization tasks in cache to prevent retry attempts on partially-initialized objects. The implementation is sound across both source-gen (TUnit.Core) and reflection (TUnit.Engine) modes, with proper thread-safety and error propagation. |
This was referenced Feb 12, 2026
This was referenced Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4715. When
InitializeAsync()starts resources (e.g. ports, background processes viaApplication.StartAsync()) then throws, TUnit was removing the failed entry from its initialization caches to allow retry. The retry callsInitializeAsync()again on the same partially-initialized shared object, which hangs because the first resources still hold ports/processes.ObjectInitializerandObjectLifecycleServicecaches — the faultedLazy<Task>/TaskCompletionSourcestays in cache so subsequent callers get the same error immediately instead of retryingObjectLifecycleService.EnsureInitializedAsyncto also checkIsCanceledso cancelled initializations don't silently return an uninitialized objectdotnet test --filter), matching the existing timeout in the streaming pathTest plan
AttributePropertyInjectionFailureTestsin TestProject fails fast (~1s), not hangingBackgroundProcessInitFailureTestsin TestProject fails fast (~1s), not hangingPropertyInjectionInitFailureTestsengine test passes (3/3 — SourceGenerated, Reflection, AOT)AttributePropertyInjectionFailureTestsengine test passes (3/3 — SourceGenerated, Reflection, AOT)🤖 Generated with Claude Code