Skip to content

Conversation

@Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Sep 4, 2025

Superceeded by #7808

Arkatufus and others added 5 commits August 21, 2025 16:02
…et#7787)

* Force synchronous start for `TestActor`

fix akkadotnet#7770

* separate creation of implicit, default `TestActor` from additional ones

* force `TestActor` to start via CTD tweak instead

* don't wait for `TestActor` to start

* Revert "don't wait for `TestActor` to start"

This reverts commit bdd77f9.

* run default `TestActor` without `CallingThreadDispatcher`

* fix TestKit deadlock during parallel test execution

This commit resolves a deadlock that occurs when running tests in parallel, where the initial TestActor creation gets stuck during async initialization with CallingThreadDispatcher.

The root cause was that SystemActorOf hardcodes async=true initialization, creating a RepointableActorRef that requires processing a Supervise system message. With CallingThreadDispatcher, this creates a circular dependency:
- TestKit constructor blocks waiting for TestActor initialization
- CallingThreadDispatcher only runs on the calling thread
- The calling thread is blocked, so Supervise message never gets processed

The solution bypasses SystemActorOf and directly calls AttachChild with async=false, enabling true synchronous initialization while preserving full system integration including supervision tree and mailbox configuration.

This maintains compatibility with CallingThreadDispatcher for deterministic testing while eliminating startup deadlocks in parallel test scenarios.

Resolves issue where TestProbe child actor creation and implicit sender functionality would fail due to incomplete TestActor initialization.

* Fix TestKit serialization issue

- Use AttachChild with isSystemService=true to exempt TestActor from serialization verification
- Resolves 700+ test failures caused by UnboundedChannelWriter serialization errors

* still working on synchronous `TestActor` startup

* Fix TestKit deadlock during parallel test execution

Resolves deadlock that occurs when TestKit instances are created in parallel
and actors try to interact with TestActor during initialization. The issue
was caused by CallingThreadDispatcher creating RepointableActorRef which
requires async initialization, leading to deadlocks.

Changes:
- Add AttachChildWithAsync internal method to ActorCell to control sync/async actor creation
- Modify TestKitBase to create TestActor synchronously (LocalActorRef) instead of async (RepointableActorRef)
- Update Xunit/Xunit2 TestKits to create logger actors synchronously
- Replace Ask with Tell for logger initialization to avoid synchronous wait deadlocks
- Add InternalsVisibleTo for Xunit TestKits to access internal Akka methods
- Maintain LoggerInitialized response for protocol compatibility (has IDeadLetterSuppression)

Fixes akkadotnet#7770

* added API approvals

* remove `EnsureTestActorReady` method

* API approvals

* ensure  calls can't get contaminated with  references

* fix API approvals

* Fix race condition in ParallelTestActorDeadlockSpec

The test had a race condition where the PingerActor sends 'ping' to TestActor
during PreStart, but the test was expecting 'test-message' first. This could
cause ExpectMsgAsync to receive the wrong message and fail.

Fixed by properly expecting the 'ping' message first before sending and
expecting the 'test-message'.
…kkadotnet#7791)

* Parameterize Incrementalist base branch for Azure DevOps pipelines

- Add dynamic incrementalist.baseBranch variable to pipeline templates
- Use System.PullRequest.TargetBranch for PR builds
- Default to 'dev' for non-PR builds
- Update all Incrementalist commands to use --branch parameter

This allows PRs targeting version branches (e.g., v1.5) to correctly
compare against their target branch instead of always using dev,
avoiding unnecessary full builds.

* Fix Incrementalist base branch detection for Azure DevOps PRs

- Use PowerShell script to extract branch name from System.PullRequest.TargetBranch
- Strip 'refs/heads/' prefix from target branch reference
- Set IncrementalistBaseBranch variable dynamically at runtime
- Update all Incrementalist commands to use the new variable

This fixes the issue where PR builds always used 'dev' as the base branch
even when targeting version branches like v1.5.
…adotnet#7793)

* Fix IIS/Windows Service console race condition (akkadotnet#7691)

- Detect when running in IIS/Windows Service environments where Console.Out
  and Console.Error are redirected to the same StreamWriter.Null singleton
- Skip console output entirely in these environments to prevent race conditions
  that cause IndexOutOfRangeException and cascade failures
- Improve DefaultLogger error handling to prevent feedback loops
- Add unit tests for non-console scenarios

The race condition occurs because:
1. IIS/Services redirect both Console.Out and Console.Error to StreamWriter.Null
2. StreamWriter.Null is a singleton, not thread-safe for concurrent access
3. Multiple threads writing to both streams cause IndexOutOfRangeException
4. Console output goes nowhere in these environments anyway

Fixes akkadotnet#7691

* Refine console detection and simplify error handling

- Make console detection more precise: only skip output when both Console.Out
  AND Console.Error point to StreamWriter.Null (the exact race condition scenario)
- Remove unnecessary try-catch in DefaultLogger.Print() since Tell() is unlikely to throw
- Keep improved error message for debugging when logger is not initialized
@Arkatufus Arkatufus closed this Sep 4, 2025
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