Commit 4f5ad0a
Fix flaky PendingTraceBufferTest by removing buffer thread race
The "continuation allows adding after root finished" test was flaky
because it started the buffer worker thread before calling
continuation.cancel(). The worker thread could process the enqueued
trace before the continuation was cancelled, causing extra mock
invocations (TooManyInvocationsError).
The fix removes buffer.start() since it's unnecessary: when the
continuation is cancelled and pendingReferenceCount drops to 0 with
rootSpanWritten still false, PendingTrace.write() is called
synchronously on the calling thread. This eliminates the race
condition entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 5ec9637 commit 4f5ad0a
1 file changed
Lines changed: 7 additions & 8 deletions
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
273 | 271 | | |
274 | 272 | | |
275 | 273 | | |
| |||
302 | 300 | | |
303 | 301 | | |
304 | 302 | | |
305 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
306 | 309 | | |
307 | | - | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
313 | | - | |
314 | 315 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 316 | + | |
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
| |||
0 commit comments