Skip to content

fix: stop Alpaca streams after provider faults - #129

Closed
stefan-jansen wants to merge 3 commits into
mainfrom
fix/alpaca-faulted-disconnect
Closed

stefan-jansen wants to merge 3 commits into
mainfrom
fix/alpaca-faulted-disconnect

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

After an order-state fault clears Alpaca connection health, public disconnect() returns without stopping the retained trading stream. Clean up retained stream/client resources regardless of the health flag, while preserving idempotent disconnect.

Closes #128.

Regression: uv run pytest -q tests/unit/test_alpaca_broker.py::test_disconnect_stops_the_stream_after_a_provider_order_fault.

  • Producing base 3ddba2d: public connect and submit start a real adapter stream task. A validated SDK TradeUpdate reaches the registered handler and poisons order state. Public disconnect then fails the regression because the transport's stop method was called zero times.
  • Fix 078b776: the unchanged workflow passes. Disconnect stops the transport, waits until its task is done, and a second disconnect does not stop it twice.
  • Only external transports are replaced. The SDK model accepts the provider payload; the adapter's own cumulative-fill validation produces the fault. Test cleanup always releases its own blocking transport, including on the failing base.
  • The final test was rerun against complete original producing source loaded from git archive. Three focused disconnect tests, Ruff check/format, ty and commit hooks passed. Full hosted qualification must pass before merge.

No release, deployment, live-money order or credentialed provider claim is included. A release requires matching Alpaca provider evidence for the changed adapter.

AI assistance: Codex reproduced the shutdown failure, implemented the cleanup correction, reviewed the diff and ran fail/pass verification.

Copilot AI balanced review requested due to automatic review settings October 17, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@stefan-jansen stefan-jansen added type: bug Confirmed or reported incorrect behavior priority: normal Normal planned work status: accepted Accepted for implementation compatibility: affected Has Python, platform, dependency, or cross-library compatibility impact labels Oct 17, 2026
@stefan-jansen

Copy link
Copy Markdown
Contributor Author

Superseded by the combined maintainer-directed maintenance PR #121 to avoid qualifying and merging this queue separately. This PR head and its regression/documentation evidence are preserved in #121 and in a verified recovery archive. The accepted issue remains open until the combined fix lands; this closure does not claim the fix is merged. Follow-up work continues in #121.

@stefan-jansen
stefan-jansen deleted the fix/alpaca-faulted-disconnect branch October 18, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility: affected Has Python, platform, dependency, or cross-library compatibility impact priority: normal Normal planned work status: accepted Accepted for implementation type: bug Confirmed or reported incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop retained Alpaca stream resources after a provider fault

2 participants