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: code-review completed Mar 12, 2026 in 8m 31s

4 issues

code-review: Found 4 issues (3 medium, 1 low)

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.

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

Duration: 8m 27s · Tokens: 6.5M in / 66.0k out · Cost: $9.40 (+extraction: $0.00, +merge: $0.00)

Annotations

Check warning on line 1073 in sentry_sdk/client.py

See this annotation in the file changed.

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

close_async() silently leaves client unclosed when used with sync transport

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.

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 when calling run_until_complete on a closed/closing loop

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.

Check warning on line 945 in tests/test_transport.py

See this annotation in the file changed.

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

Excessive test parameterization creates combinatorial explosion

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.