Skip to content

fix: Suppress mypy await type error in AsyncHttpTransport._request

82c0094
Select commit
Loading
Failed to load commit list.
Merged

feat: Add experimental async transport (port of PR #4572) #5646

fix: Suppress mypy await type error in AsyncHttpTransport._request
82c0094
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 12, 2026 in 14m 35s

2 issues

code-review: Found 2 issues (2 medium)

Medium

RuntimeError possible when running _flush() on a stopped loop - `sentry_sdk/integrations/asyncio.py:80-88`

In patch_loop_close, the _patched_close() function calls loop.run_until_complete(_flush()) on a loop that may already be in a stopped state or have pending tasks being cancelled. If loop.run_until_complete() is called when the loop is already running (which shouldn't happen during close) or after the loop has been finalized, it will raise a RuntimeError. The current exception handling catches this broadly, but the _flush() coroutine performs async operations (await client.close_async()) that may not complete gracefully during shutdown.

SOCKS proxy failure passes invalid `proxy_headers` to AsyncConnectionPool - `sentry_sdk/transport.py:952-956`

When a SOCKS proxy is configured but httpcore.AsyncSOCKSProxy fails with a RuntimeError (line 952), the code falls through to line 960 and returns httpcore.AsyncConnectionPool(**opts). However, opts still contains proxy_headers added at line 940, which is not a valid parameter for AsyncConnectionPool. This will cause a TypeError at runtime when users configure a SOCKS proxy with proxy headers and the SOCKS support is not installed.


Duration: 14m 25s · Tokens: 4.8M in / 54.7k out · Cost: $6.71 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 88 in sentry_sdk/integrations/asyncio.py

See this annotation in the file changed.

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

RuntimeError possible when running _flush() on a stopped loop

In `patch_loop_close`, the `_patched_close()` function calls `loop.run_until_complete(_flush())` on a loop that may already be in a stopped state or have pending tasks being cancelled. If `loop.run_until_complete()` is called when the loop is already running (which shouldn't happen during close) or after the loop has been finalized, it will raise a RuntimeError. The current exception handling catches this broadly, but the `_flush()` coroutine performs async operations (`await client.close_async()`) that may not complete gracefully during shutdown.

Check warning on line 956 in sentry_sdk/transport.py

See this annotation in the file changed.

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

SOCKS proxy failure passes invalid `proxy_headers` to AsyncConnectionPool

When a SOCKS proxy is configured but `httpcore.AsyncSOCKSProxy` fails with a RuntimeError (line 952), the code falls through to line 960 and returns `httpcore.AsyncConnectionPool(**opts)`. However, `opts` still contains `proxy_headers` added at line 940, which is not a valid parameter for `AsyncConnectionPool`. This will cause a `TypeError` at runtime when users configure a SOCKS proxy with proxy headers and the SOCKS support is not installed.