Visitar URL original
fix: await aiohttp server handler on collector-address skip by songzhendong · Pull Request #423 · apache/skywalking-python · GitHub
Skip to content

fix: await aiohttp server handler on collector-address skip - #423

Merged
wu-sheng merged 3 commits into
apache:masterfrom
songzhendong:fix/aiohttp-server-collector-skip
Oct 8, 2026
Merged

wu-sheng merged 3 commits into
apache:masterfrom
songzhendong:fix/aiohttp-server-collector-skip

Conversation

@songzhendong

@songzhendong songzhendong commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What happened

When SW_AGENT_PROTOCOL=http and an inbound aiohttp request's
host:port matches SW_AGENT_COLLECTOR_BACKEND_SERVICES, the
sw_aiohttp plugin skips Entry-span creation for that request.
The skip path returned the unbound _handle_request function
object instead of awaiting it.

aiohttp then does resp, reset = await task and raises
TypeError: cannot unpack non-iterable function object. The
connection is force-closed; the process itself does not crash.

This is the server-side counterpart of the client bug fixed in #422
(return _request → return await _request(...)).

How to fix

Await the original handler with the same signature as the traced path,
and keep the skip (no Entry span):

return await _handle_request(self, request, start_time, *args, **kwargs)

Changes

  • skywalking/plugins/sw_aiohttp.py: fix collector-address skip on
    RequestHandler._handle_request
  • tests/unit/test_http_reporter.py: unit coverage for skip (must await,
    no get_context) and non-skip (still creates Entry span)

Test plan

  • pytest -v tests/unit/test_http_reporter.py
  • CI

Notes

  • Default protocol=grpc never hits this branch.
  • Trigger requires aiohttp server + protocol=http + inbound
    host:port matching the collector address (uncommon in production,
    request-level failure when it does).

Skip must call the original RequestHandler._handle_request, not return the
function object. Otherwise aiohttp unpacks a function as (resp, reset) and
the inbound request fails.
@wu-sheng wu-sheng added this to the 1.4.0 milestone Oct 8, 2026
@wu-sheng wu-sheng added the bug Something isn't working label Oct 8, 2026
@wu-sheng
wu-sheng merged commit 822db03 into apache:master Oct 8, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants