Skip to content

test(tui): await reset cancellation before daemon stop release#1536

Merged
Aaronontheweb merged 1 commit into
netclaw-dev:devfrom
Aaronontheweb:fix-init-dispose-daemon-stop-race
Jul 1, 2026
Merged

test(tui): await reset cancellation before daemon stop release#1536
Aaronontheweb merged 1 commit into
netclaw-dev:devfrom
Aaronontheweb:fix-init-dispose-daemon-stop-race

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

  • fix the dispose-during-reset test to wait for the fake daemon stop token to observe cancellation
  • remove the weak dispose-start signal that could release the daemon stop before Dispose cancelled the reset
  • keep this separate from the Slack processing-status PR

Validation

  • dotnet test src/Netclaw.Cli.Tests/Netclaw.Cli.Tests.csproj --filter FullyQualifiedName~InitExistingInstallViewModelTests
  • dotnet test src/Netclaw.Cli.Tests/Netclaw.Cli.Tests.csproj
  • dotnet test -c Release src/Netclaw.Cli.Tests/Netclaw.Cli.Tests.csproj --filter FullyQualifiedName~Dispose_WhileDaemonStopIsInFlight_CancelsLaterProgressAndNavigation
  • dotnet slopwatch analyze
  • pwsh ./scripts/Add-FileHeaders.ps1 -Verify
  • git diff --check

@Aaronontheweb Aaronontheweb added tests All issues related to testing, quality assurance, and smoke testing. bug Something isn't working tui Terminal UI (Termina) issues labels Jun 30, 2026

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb
Aaronontheweb marked this pull request as ready for review July 1, 2026 00:02
@Aaronontheweb
Aaronontheweb merged commit eb01b49 into netclaw-dev:dev Jul 1, 2026
15 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix-init-dispose-daemon-stop-race branch July 1, 2026 00:02
Aaronontheweb added a commit that referenced this pull request Jul 3, 2026
…p 3 (#1573)

RunResetAsync publishes CurrentProgressStep = 3 ("Purge complete") and then
evaluates the Task.Delay(CompletionPause, _timeProvider, ct) that registers the
completion-pause timer. Because RunResetAsync runs off the loop, step 3 is the
signal observers gate on to know deletion finished — but it fired BEFORE the
timer it vouches for existed. On a virtualized clock (FakeTimeProvider in tests,
and any consumer advancing the injected TimeProvider) this is a lost wakeup: an
Advance that lands between "step 3 published" and "timer registered" is dropped,
the delay never fires, and the reset hangs forever awaiting a wakeup that will
never come.

Fix: create the completion-pause timer before publishing step 3, then await the
captured task. This makes "step 3 observed" a happens-before guarantee that the
pause timer already exists, so a single clock advance always fires it
deterministically. On the real clock this shifts timer registration a few
microseconds earlier; the visible "Purge complete" dwell is unchanged.

Evidence: hang-dump forensics of CI run 28676578217 (PR #1568, Netclaw.Cli.Tests
blame-hang after 300s). Test FullReset_AfterBothConfirmations_DeletesEverything
was parked at `await vm.ResetTask!.WaitAsync(ct)`; its CompleteResetAsync helper
had exhausted its advance loop (counter i == 10, all virtual-clock advances
spent) and FakeTimeProvider was left holding exactly one orphaned waiter — the
delay registered after the final Advance. Prior commits 850cf8c (#1525) and
eb01b49 (#1536) band-aided the symptom with advance/yield retry loops; this
removes the race at the source.

The test helper CompleteResetAsync is shared by all three sibling tests
(FullReset_AfterBothConfirmations_DeletesEverything,
SetupOnlyReset_DeletesConfigButKeepsMemoryAndSessions,
DaemonStopFailureResult_ShowsStatusAndContinuesReset); it now waits for step 3
then does exactly one advance, deleting the retry loop that only ever masked the
lost wakeup on loaded runners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tests All issues related to testing, quality assurance, and smoke testing. tui Terminal UI (Termina) issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant