Skip to content

Fix graceful websocket reconnect and release 0.2.2 - #13

Merged
nekrasovp merged 1 commit into
mainfrom
fix/graceful-websocket-reconnect
Sep 11, 2026
Merged

nekrasovp merged 1 commit into
mainfrom
fix/graceful-websocket-reconnect

Conversation

@nekrasovp

Copy link
Copy Markdown
Contributor

Summary

A graceful websocket EOF left all three venue clients reporting healthy and repeatedly reading the exhausted stream without backoff. Polymarket, Kalshi, and Opinion now mark the connection down, increment reconnect_count once, wait for backoff, reconnect and restore the saved subscription. Opinion stops its old heartbeat before waiting and starts a new one after connecting.

Explicit close interrupts retry waits. Cancelling or closing the message iterator releases the socket/heartbeat without reconnecting; repeated close is safe, and explicit connect starts a new session. Prepare patch release 0.2.2, with CHANGELOG and lifecycle/agent documentation.

Refs #12. Keep the issue open until public PyPI installation and artifact identity verification succeed.

Validation

  • uv sync --group dev
  • uv run ruff check .
  • uv run mypy — 25 source files
  • uv run pytest -q -s94 passed, including 36 new lifecycle regression cases
  • uv build
  • uv run twine check dist/* — wheel and sdist passed
  • uv run mkdocs build --strict
  • git diff --check

The three graceful-EOF cases fail on baseline 0.2.1 (80d80a0556cb30d8c4622cc6c92c2f980822d59b) with a bounded assertion detecting repeated reads of an exhausted socket; they pass on this change. Tests cover normal EOF, transport errors, exact backoff/reconnect/subscription counts, health, Opinion heartbeat replacement, raw payloads, close/cancel/manager stop during idle reads and one-hour retry waits, repeated close, explicit restart, and close during connection establishment.

Exact commit 0c60aa9b95fc9fb47ad8c8d8b289a72460bc506f passed the full gate in a clean git clone --no-local on Python 3.12 (94 passed; clean before/after). The worktree gate also passed on Python 3.14. Separate fresh Python 3.12 environments installed the wheel and sdist, verified public imports and version, and each passed all 36 regressions with current public dependencies, including websockets 17.1.

Boundary

  • Keeps predxt read-only; parser/raw payload contract and public imports are preserved.
  • No real secrets or account data in code, tests, or docs; all network/auth behavior in regression tests is stubbed.
  • Public lifecycle docs / llms.txt updated.

Only predxt changes are included. PyPI publication remains a separate release.yml Trusted Publishing step after CI and merge.

Refs #12. Restore subscriptions after EOF and make retry waits interruptible by close.
@nekrasovp
nekrasovp merged commit e2bc5ed into main Sep 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant