Skip to content

Sync and async clients use different keep-alive settings #241

Closed

Description

@MarTrepodi

Bug Description

Only the async client overrides the connection pool limits. It sets httpx.Limits(keepalive_expiry=None) in swgoh_comlink_async.py, so idle pooled connections are kept forever. The sync client uses the httpx default, which closes them after 5 s idle. The git history (db474a4) gives no reason for the difference.

When an idle connection has been closed on the other side, by a Comlink restart or a NAT/router idle timeout, the next request on it can fail with httpx.RemoteProtocolError. _send raises that at once as a transport error, with no retry.

Steps to Reproduce

from swgoh_comlink import SwgohComlink, SwgohComlinkAsync
SwgohComlink().client._transport._pool._keepalive_expiry
SwgohComlinkAsync().client._transport._pool._keepalive_expiry

Expected Behavior

Both clients use the same connection limits.

Actual Behavior

Reproduced on develop (9cc3760): the sync client gives 5.0, the async client gives None.

Suggested Fix

  • Remove the async override, so both clients use the httpx default limits (5 s idle keep-alive).
  • Add an optional keyword-only limits: httpx.Limits | None = None to both constructors for callers who need something else.
  • Leave request timeouts unchanged. /data keeps its longer GAME_DATA_TIMEOUT.

Acceptance

  • Both clients build their httpx clients with identical limits.
  • A unit test asserts that sync and async pass the same limits to httpx.
  • A docs/migration.md entry for the async keep-alive change.

If stale-connection failures continue after this change, retrying transport errors gets its own issue. That would change the documented retry contract (only 429, 503 and rate refusals are retried today).

Activity

  1. added
    bug
    on Nov 7, 2026
  2. github-actions commented on Nov 7, 2026

    @github-actions
    Contributor

    Addressed by #258, which is now merged into develop. This issue will close automatically when that change is released to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions