feat: Add experimental async transport (port of PR #4572) #5646
6 issues
Medium
Test for async transport flush never executes the code path it claims to test - `tests/integrations/asyncio/test_asyncio.py:665-667`
The _flush() function in patch_loop_close() uses isinstance(client.transport, AsyncHttpTransport) to check the transport type. However, Mock(spec=AsyncHttpTransport) is not an actual instance of AsyncHttpTransport - it's a Mock object. The isinstance() check will return False, causing the function to return early on line 72 without calling close_async(). The test may still pass because MagicMock.assert_called_once() doesn't fail when the mock wasn't called if you're using AsyncMock in certain configurations, but the test doesn't actually exercise the intended code path.
Context manager __exit__ silently fails to close AsyncHttpTransport - `sentry_sdk/client.py:1041-1048`
The _Client's exit method (line 1137) calls close(), but close() (lines 1041-1052) silently returns early when transport is AsyncHttpTransport without flushing or closing anything. Users using with Client(...) context manager with async transport enabled will have data silently lost. The class also lacks aexit to support async with patterns, though this is outside the hunk.
Also found at:
sentry_sdk/integrations/asyncio.py:80-88sentry_sdk/integrations/asyncio.py:71-74
Low
Missing test cleanup may cause test isolation issues - `tests/test_transport.py:1017`
The test test_async_transport_background_thread_capture sets a client on the global scope with sentry_sdk.get_global_scope().set_client(client) but does not clean it up with a finalizer. This can cause test isolation issues where the client leaks into subsequent tests, potentially causing flaky test failures or incorrect test results.
Also found at:
tests/test_transport.py:1047
Parametrized test creates excessive test combinations - `tests/test_transport.py:926-932`
The test test_transport_works_async uses 5 parametrized decorators creating 2×2×2×3×4 = 96 test combinations. This can significantly slow down the test suite. Consider reducing combinations or using hypothesis for property-based testing of the compression parameters.
Missing space in assertion error message makes output harder to read - `tests/test_client.py:1905-1906`
The f-string concatenation on lines 1905-1906 lacks a space between the two strings, resulting in a message like 'SOCKS == Truebut got' instead of 'SOCKS == True but got'. This affects the readability of test failure messages but has no functional impact.
Missing test cleanup for global scope client in test_async_transport_concurrent_requests - `tests/test_transport.py:1074`
The test sets sentry_sdk.get_global_scope().set_client(client) at line 1074 but does not add a finalizer to clean it up. This can cause test pollution - if subsequent tests rely on the global scope being clean, they may fail or behave unexpectedly. Other tests in the same file (e.g., test_async_transport_rate_limiting_with_concurrency at line 1098) correctly use request.addfinalizer(lambda: sentry_sdk.get_global_scope().set_client(None)).
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 3 | 13m 4s | $7.75 |
| find-bugs | 3 | 10m 26s | $15.38 |
| skill-scanner | 0 | 16m 52s | $1.27 |
| security-review | 0 | 15m 8s | $4.54 |
Duration: 55m 30s · Tokens: 19.9M in / 172.7k out · Cost: $28.99 (+extraction: $0.02, +merge: $0.00, +fix_gate: $0.01, +dedup: $0.01)