Skip to content

fix: Cancel _target task in AsyncWorker.kill() and improve sync close()

c46fb6f
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

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

fix: Cancel _target task in AsyncWorker.kill() and improve sync close()
c46fb6f
Select commit
Loading
Failed to load commit list.
GitHub Actions / warden: find-bugs completed Mar 12, 2026 in 16m 33s

4 issues

find-bugs: Found 4 issues (1 high, 2 medium, 1 low)

High

Test test_loop_close_flushes_async_transport will always fail due to isinstance check on Mock object - `tests/integrations/asyncio/test_asyncio.py:665-670`

The test creates mock_transport = Mock(spec=AsyncHttpTransport) but the production code patch_loop_close() uses isinstance(client.transport, AsyncHttpTransport) to check if the transport is async. A Mock object with spec= does NOT satisfy isinstance checks - it only makes the mock have the same attributes/methods. Therefore, _flush() returns early at line 71-72 without calling close_async(), causing assert_called_once() to fail. The test needs to patch the isinstance check or use a real AsyncHttpTransport instance.

Medium

SOCKS proxy failure silently creates direct connection instead of intended fallback - `sentry_sdk/transport.py:952-956`

When httpcore.AsyncSOCKSProxy() raises a RuntimeError (indicating SOCKS support is not installed), the exception is caught and a warning is logged about 'Disabling proxy support', but the code then falls through without returning, causing execution to continue to line 960 which creates an AsyncConnectionPool without proxy settings. This bypasses the user's intended proxy configuration entirely, potentially leaking traffic that was meant to go through a SOCKS proxy - a security/privacy concern if the proxy was being used for anonymity or network isolation.

AsyncWorker.kill() leaves terminator in queue, causing immediate shutdown on restart - `sentry_sdk/worker.py:29-31`

In AsyncWorker.kill(), a _TERMINATOR is added to the queue (line 220) but the queue reference is never cleared (self._queue = None is missing). If start() is called again, the old queue is reused (line 237 check fails), and the new consumer task will immediately process the stale terminator and exit. This makes the worker non-restartable without creating a new instance.

Low

Missing space in test assertion error message creates malformed output - `tests/test_client.py:1905-1906`

The f-string assertion message on lines 1905-1906 is missing a space between the two string parts. When should_be_socks_proxy is True/False and the assertion fails, the message will read "SOCKS == Truebut got" or "SOCKS == Falsebut got" instead of "SOCKS == True but got" or "SOCKS == False but got". This makes test failure messages harder to read.


Duration: 16m 23s · Tokens: 11.0M in / 66.4k out · Cost: $14.38 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)

Annotations

Check failure on line 670 in tests/integrations/asyncio/test_asyncio.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

Test test_loop_close_flushes_async_transport will always fail due to isinstance check on Mock object

The test creates `mock_transport = Mock(spec=AsyncHttpTransport)` but the production code `patch_loop_close()` uses `isinstance(client.transport, AsyncHttpTransport)` to check if the transport is async. A `Mock` object with `spec=` does NOT satisfy `isinstance` checks - it only makes the mock have the same attributes/methods. Therefore, `_flush()` returns early at line 71-72 without calling `close_async()`, causing `assert_called_once()` to fail. The test needs to patch the `isinstance` check or use a real `AsyncHttpTransport` instance.

Check warning on line 956 in sentry_sdk/transport.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

SOCKS proxy failure silently creates direct connection instead of intended fallback

When `httpcore.AsyncSOCKSProxy()` raises a RuntimeError (indicating SOCKS support is not installed), the exception is caught and a warning is logged about 'Disabling proxy support', but the code then falls through without returning, causing execution to continue to line 960 which creates an `AsyncConnectionPool` without proxy settings. This bypasses the user's intended proxy configuration entirely, potentially leaking traffic that was meant to go through a SOCKS proxy - a security/privacy concern if the proxy was being used for anonymity or network isolation.

Check warning on line 31 in sentry_sdk/worker.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

AsyncWorker.kill() leaves terminator in queue, causing immediate shutdown on restart

In `AsyncWorker.kill()`, a `_TERMINATOR` is added to the queue (line 220) but the queue reference is never cleared (`self._queue = None` is missing). If `start()` is called again, the old queue is reused (line 237 check fails), and the new consumer task will immediately process the stale terminator and exit. This makes the worker non-restartable without creating a new instance.