feat: Add experimental async transport (port of PR #4572) #5646
3 issues
code-review: Found 3 issues (2 medium, 1 low)
Medium
close_async() and __aexit__ silently skip cleanup for sync transport - `sentry_sdk/client.py:1066-1073`
close_async() returns early without calling _close_components() or transport.kill() when used with a sync transport. This means if someone uses async with client: context manager with a sync transport, neither the session flusher, batchers, monitor, nor the transport itself will be properly cleaned up. The sync close() should be called as a fallback to ensure resources are released.
Also found at:
tests/integrations/asyncio/test_asyncio.py:665-673
httpcore[asyncio] added to common environment incompatible with Python 3.6 and 3.7 - `tox.ini:340`
The change adds common: httpcore[asyncio] as a dependency for all common test environments. However, httpcore 1.x (which is specified in setup.py via httpcore[asyncio]==1.*) requires Python >=3.8. The common environment includes Python 3.6 and 3.7 configurations (line 21: {py3.6,py3.7,...}-common), which will cause pip installation failures when tox tries to install this dependency on those Python versions.
Low
Missing test coverage for async transport fallback scenarios - `sentry_sdk/transport.py:1155-1175`
The make_transport function has multiple fallback paths when async transport is requested but cannot be used: (1) no event loop running, (2) AsyncioIntegration not enabled, (3) httpcore[asyncio] not installed. None of these fallback paths have explicit test coverage to verify the warning messages are logged and sync transport is correctly used instead. This could lead to regressions in the fallback behavior going unnoticed.
Duration: 9m 24s · Tokens: 6.2M in / 66.3k out · Cost: $8.09 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check warning on line 1073 in sentry_sdk/client.py
sentry-warden / warden: code-review
close_async() and __aexit__ silently skip cleanup for sync transport
`close_async()` returns early without calling `_close_components()` or `transport.kill()` when used with a sync transport. This means if someone uses `async with client:` context manager with a sync transport, neither the session flusher, batchers, monitor, nor the transport itself will be properly cleaned up. The sync `close()` should be called as a fallback to ensure resources are released.
Check warning on line 673 in tests/integrations/asyncio/test_asyncio.py
sentry-warden / warden: code-review
[BPC-NTB] close_async() and __aexit__ silently skip cleanup for sync transport (additional location)
`close_async()` returns early without calling `_close_components()` or `transport.kill()` when used with a sync transport. This means if someone uses `async with client:` context manager with a sync transport, neither the session flusher, batchers, monitor, nor the transport itself will be properly cleaned up. The sync `close()` should be called as a fallback to ensure resources are released.
Check warning on line 340 in tox.ini
sentry-warden / warden: code-review
httpcore[asyncio] added to common environment incompatible with Python 3.6 and 3.7
The change adds `common: httpcore[asyncio]` as a dependency for all common test environments. However, `httpcore` 1.x (which is specified in setup.py via `httpcore[asyncio]==1.*`) requires Python >=3.8. The common environment includes Python 3.6 and 3.7 configurations (line 21: `{py3.6,py3.7,...}-common`), which will cause pip installation failures when tox tries to install this dependency on those Python versions.