Skip to content

Attach an async handler's pending future to the receiving actor - #230

Merged
resetius merged 1 commit into
masterfrom
fix-228
Nov 19, 2026
Merged

resetius merged 1 commit into
masterfrom
fix-228

Conversation

@resetius

Copy link
Copy Markdown
Owner

TActorContext::StartAsync() built TAsync with Sender_.ActorId(), so the pending future of an async handler (TBehavior::Receive returning TFuture<void>, ICoroActor::CoReceive) was attached to the sender's slot. With several actors serving one sender, each AddPendingFuture overwrote the previous future and all but the last handler never finished.

The fix uses Self_.ActorId().

Test: test_async_handler_scatter_gather in tests/test_actors.cpp (a boss sends work to 4 workers whose async Receive sleeps and then replies; all 4 replies must arrive). It fails on master in Release (1 != 4) and passes with the fix.

Fixes #228

TActorContext::StartAsync() used Sender_.ActorId(), so the pending future
of an async handler was stored in the sender's slot. With several actors
serving one sender (scatter/gather) each AddPendingFuture overwrote the
previous one and all but the last handler never finished.

Use Self_.ActorId() and add a regression test with a boss and 4 workers
whose async Receive sleeps before replying.

Fixes #228
@github-actions

Copy link
Copy Markdown

Unit Test Results (Linux)

337 tests  +1   337 ✅ +1   26s ⏱️ -1s
  4 suites ±0     0 💤 ±0 
  4 files   ±0     0 ❌ ±0 

Results for commit 1332b5b. ± Comparison against base commit b559459.

@github-actions

Copy link
Copy Markdown

Unit Test Results (MacOS)

257 tests  +1   257 ✅ +1   32s ⏱️ -2s
  4 suites ±0     0 💤 ±0 
  4 files   ±0     0 ❌ ±0 

Results for commit 1332b5b. ± Comparison against base commit b559459.

@github-actions

Copy link
Copy Markdown

Unit Test Results (Windows)

178 tests  +1   178 ✅ +1   45s ⏱️ ±0s
  4 suites ±0     0 💤 ±0 
  4 files   ±0     0 ❌ ±0 

Results for commit 1332b5b. ± Comparison against base commit b559459.

@resetius
resetius merged commit d5411f6 into master Nov 19, 2026
7 checks passed
@resetius
resetius deleted the fix-228 branch November 19, 2026 23:32
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.

TActorContext::StartAsync attaches the pending future to the sender instead of the receiving actor

1 participant