feat: Auto-create traces for MAUI navigation events #5111
1 issue
code-review: Found 1 issue (1 medium)
Medium
ChildSpanFinished may throw ObjectDisposedException due to race with Finish() - `src/Sentry/TransactionTracer.cs:336`
The ChildSpanFinished method checks _hasFinished before calling _idleTimer?.Start(), but there's a race condition: Finish() could be invoked concurrently between the check and the Start() call. Finish() disposes the timer after setting _hasFinished, so Start() would then throw ObjectDisposedException. The similar method ResetIdleTimeout (line 395-403) explicitly handles this race with a try-catch, but ChildSpanFinished does not. This could cause runtime exceptions when a span finishes while the transaction is concurrently finishing.
Duration: 6m 36s · Tokens: 4.6M in / 55.5k out · Cost: $7.34 (+extraction: $0.00)
Annotations
Check warning on line 336 in src/Sentry/TransactionTracer.cs
sentry-warden / warden: code-review
ChildSpanFinished may throw ObjectDisposedException due to race with Finish()
The `ChildSpanFinished` method checks `_hasFinished` before calling `_idleTimer?.Start()`, but there's a race condition: `Finish()` could be invoked concurrently between the check and the `Start()` call. `Finish()` disposes the timer after setting `_hasFinished`, so `Start()` would then throw `ObjectDisposedException`. The similar method `ResetIdleTimeout` (line 395-403) explicitly handles this race with a try-catch, but `ChildSpanFinished` does not. This could cause runtime exceptions when a span finishes while the transaction is concurrently finishing.