Skip to content

Fix graceful websocket EOF reconnect and release 0.2.2 #12

Description

@nekrasovp

Defect

In predxt 0.2.1, messages() in PolymarketWsClient, KalshiWsClient, and OpinionWsClient handles ConnectionClosed/OSError, but normal exhaustion of the websocket async iterator immediately re-enters the read loop. Connection health remains true, reconnect_count is unchanged, no backoff/reconnect/resubscribe occurs, and Opinion's heartbeat remains active.

Risks: ingestion stops while reporting healthy; repeatedly iterating an exhausted stream can spin without yielding and consume CPU, preventing timely cancellation.

Downstream evidence reported by the integration task: an application snapshot passed 696 tests (1 skipped) with a runtime substitution using predxt, but test_messages_backoff_when_stream_ends_normally reproducibly hung. This issue addresses the SDK only; no downstream application or production changes are included.

Acceptance criteria

  • All three clients mark connection health false on graceful EOF, increment reconnect_count once, wait for backoff, reconnect and restore the subscription.
  • Opinion stops the old heartbeat before waiting and creates a heartbeat for the recovered connection.
  • Explicit close, manager stop and cancellation do not initiate reconnect; shutdown is prompt and repeatable, including during backoff.
  • Deterministic regression tests cover all three venues, bounded iteration/no busy loop, exact reconnect/resubscribe counts, health, heartbeat and raw payload/import compatibility.
  • Full AGENTS.md validation passes, plus clean clone and isolated wheel/sdist installation checks.
  • Release next patch via the repository's release.yml Trusted Publishing workflow; verify CI and publish success.
  • Install the released package from public PyPI in a fresh environment, verify version, all client imports, graceful reconnect regression smoke and artifact SHA256 against PyPI JSON.
  • Attach PR, exact commit, tag, GitHub Release, PyPI and validation evidence; close only after successful public installation.

Release target

Live PyPI JSON checked on 2026-09-11: latest 0.2.1; existing versions 0.1.0, 0.2.0, 0.2.1. Target patch: 0.2.2. Starting origin/main: 80d80a0556cb30d8c4622cc6c92c2f980822d59b.

Released

Resolved in PR #13, commit e2bc5ed4b73272dfa414aafb133f718176b09283, tag v0.2.2. GitHub Release and PyPI 0.2.2 are public. Fresh public wheel and sdist installations each passed all 36 lifecycle regressions; full validation and artifact hashes are recorded in the closing evidence comment.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions