feat: Add experimental async transport (port of PR #4572) #5646
3 issues
code-review: Found 3 issues (1 medium, 2 low)
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.
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.
Duration: 13m 4s · Tokens: 5.7M in / 61.5k out · Cost: $7.77 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.00)
Annotations
Check warning on line 667 in tests/integrations/asyncio/test_asyncio.py
github-actions / warden: code-review
Test for async transport flush never executes the code path it claims to test
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.