Skip to content

safe exit pattern

8435f36
Select commit
Loading
Failed to load commit list.
Merged

fix(litellm): Avoid double span exits when streaming #5933

safe exit pattern
8435f36
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Apr 13, 2026 in 1m 40s

1 issue

code-review: Found 1 issue (1 medium)

Medium

Failure callback lacks streaming-aware span handling - `sentry_sdk/integrations/litellm.py:237`

The _success_callback now correctly pops the span from metadata to prevent double exits during streaming, but _failure_callback still uses .get() instead of .pop() and doesn't check for streaming status. If failure_callback is also invoked multiple times during streaming (similar to success callbacks), or if both callbacks fire for the same request, this could still cause double span exits or resource leaks.


Duration: 1m 40s · Tokens: 693.3k in / 6.5k out · Cost: $1.12

Annotations

Check warning on line 237 in sentry_sdk/integrations/litellm.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Failure callback lacks streaming-aware span handling

The `_success_callback` now correctly pops the span from metadata to prevent double exits during streaming, but `_failure_callback` still uses `.get()` instead of `.pop()` and doesn't check for streaming status. If `failure_callback` is also invoked multiple times during streaming (similar to success callbacks), or if both callbacks fire for the same request, this could still cause double span exits or resource leaks.