Commit a475145
fix(selftest): eliminate timer-vs-cancel race in DepsThrashing fixture (#200)
* fix(selftest): eliminate timer-vs-cancel race in DepsThrashing fixture
DepsThrashing_AtMostOneCompleted hit completed=2 on CI Stress run
#25518410339 (shards 5 and 10). The previous fix (ThrowIfCancellationRequested
after Task.Delay(200)) left a TOCTOU window: if the pool thread's CT check
ran before the UI thread's Cts.Cancel() completed, the counter incremented
for a fetch the production hook correctly discards.
Root cause: when CI render ticks approach 200ms, the delay timer and dep-change
cancellation fire nearly simultaneously on different threads, making the race
likely rather than theoretical.
Fix: replace Task.Delay(200, ct) with Task.Delay(Timeout.Infinite, ct). An
infinite-duration delay can only exit via OperationCanceledException — there
is no timer to race against. completed stays 0; the assertion guards against
regressions. Remove the now-unreachable ThrowIfCancellationRequested() and the
Harness.Render(400) wait that existed solely to let the last fetch resolve.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fixup: address CR feedback on DepsThrashing fixture
Two issues raised in review of #200:
1. host.Dispose() before GC drain: the last dep's Task.Delay(Infinite, ct)
ran forever with no explicit teardown. Disposing the host triggers the
UseEffect cleanup which cancels the CTS, ensuring the in-flight task is
torn down before the unobserved-exception probe runs.
2. Tighten completed==0: the comment said "completed stays 0" but the
assertion was completed<=1. Changed to completed==0 so the fixture
actually catches a regression if a completion slips through.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent c363bdf commit a475145
1 file changed
Lines changed: 12 additions & 15 deletions
Lines changed: 12 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
| |||
101 | 97 | | |
102 | 98 | | |
103 | 99 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 100 | | |
108 | 101 | | |
109 | 102 | | |
| |||
117 | 110 | | |
118 | 111 | | |
119 | 112 | | |
120 | | - | |
| 113 | + | |
| 114 | + | |
121 | 115 | | |
122 | | - | |
| 116 | + | |
123 | 117 | | |
124 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
| |||
0 commit comments