Skip to content

fix: Skip async tests under gevent

5ea3aac
Select commit
Loading
Failed to load commit list.
Open

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

fix: Skip async tests under gevent
5ea3aac
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Mar 12, 2026 in 17m 20s

9 issues

Medium

close_async() silently leaves client unclosed when used with sync transport - `sentry_sdk/client.py:1066-1073`

When close_async() is called on a client with a sync transport, it logs only at DEBUG level and returns without closing the client. The transport remains active and resources are not released. This is problematic especially for __aexit__ (line 1144-1145) which calls close_async() - using async with client: with a sync transport will silently leave the client unclosed, potentially causing resource leaks.

RuntimeError when calling run_until_complete on a closed/closing loop - `sentry_sdk/integrations/asyncio.py:80-88`

In _patched_close(), calling loop.run_until_complete(_flush()) may raise a RuntimeError if the loop is already in the process of stopping or if this is called from within an async context. The current exception handling catches all exceptions and logs them, but this could mask underlying issues or result in events not being flushed. Additionally, if the loop is being closed from within a coroutine, run_until_complete will fail.

Excessive test parameterization creates combinatorial explosion - `tests/test_transport.py:932-945`

The test_transport_works_async test at line 932 has 5 parametrized dimensions: debug (2), client_flush_method (2), use_pickle (2), compression_level (3), and compression_algo (4). This creates 2×2×2×3×4 = 96 test combinations. Combined with inherent async test overhead, this may significantly slow down CI runs and makes debugging failures difficult.

close_async() silently returns without cleanup when used with non-async transport - `sentry_sdk/client.py:1066-1073`

When close_async() is called with a non-async (sync) transport, it logs a debug message and returns early without calling _close_components() or transport.kill(). This means components like session_flusher, log_batcher, metrics_batcher, span_batcher, and monitor are never killed, leaving background threads running. While the docstring says to use close() instead, returning silently without cleanup can cause resource leaks if the user mistakenly calls close_async().

Also found at:

  • tests/integrations/asyncio/test_asyncio.py:665-673
Race condition in rate limiting test may cause intermittent failures - `tests/test_transport.py:1121-1122`

The test test_async_transport_rate_limiting_with_concurrency at line 1122 asserts that rate limiting is enabled (_check_disabled("error") is True) after sending a message and sleeping for 0.1 seconds. However, in async context, the message goes through an async queue and network request. Under load or slow CI conditions, 0.1 seconds may not be enough for the request to complete and update the rate limit state, causing intermittent test failures.

httpcore[asyncio] dependency breaks Python 3.6/3.7 test environments - `tox.ini:340`

The common: httpcore[asyncio] dependency on line 340 applies to all Python versions in the common test environment, but httpcore requires Python 3.8+. This will cause installation failures for py3.6-common and py3.7-common test environments. The dependency should be version-gated like other version-specific dependencies (e.g., {py3.8,py3.9,...}-common: httpcore[asyncio]).

Low

Test may leave global scope in modified state on failure - `tests/test_transport.py:1012-1014`

The test_async_transport_background_thread_capture test at line 1004 sets the global scope's client via sentry_sdk.get_global_scope().set_client(client) but doesn't register a cleanup finalizer. If the test fails before await client.close_async(), the global scope remains modified for subsequent tests, potentially causing flaky test behavior.

Also found at:

  • tests/test_transport.py:1046-1047
Async client resources leak if test assertions fail before close_async() - `tests/test_client.py:1808-1817`

The test creates an AsyncHttpTransport client but only calls await client.close_async() at the very end of the test. If any assertion fails before reaching this line, the async connection pool (httpcore.AsyncConnectionPool or proxy variants) and the AsyncWorker task will not be properly closed. This can lead to resource warnings, connection leaks, and potentially flaky test behavior when running the test suite.

Also found at:

  • tests/test_transport.py:1089
Missing space in assertion error message causes unreadable output on test failure - `tests/test_client.py:1918-1919`

The f-string concatenation on lines 1918-1919 lacks a space between the two strings. When the test fails, the error message will display as 'SOCKS == Truebut got' or 'SOCKS == Falsebut got' instead of the intended 'SOCKS == True but got'. This makes test failure diagnosis harder. The same bug exists in the original sync test (test_socks_proxy).

4 skills analyzed
Skill Findings Duration Cost
code-review 4 8m 27s $9.40
find-bugs 5 16m 9s $14.81
skill-scanner 0 17m 1s $2.87
security-review 0 14m 43s $4.88

Duration: 56m 21s · Tokens: 20.6M in / 176.8k out · Cost: $32.02 (+extraction: $0.03, +merge: $0.01, +dedup: $0.02, +fix_gate: $0.02)