Skip to content

Start the WebSocket manager only after Info metadata initialization succeeds - #349

Open
yutianjiang39 wants to merge 1 commit into
hyperliquid-dex:masterfrom
yutianjiang39:fix/info-websocket-after-metadata
Open

yutianjiang39 wants to merge 1 commit into
hyperliquid-dex:masterfrom
yutianjiang39:fix/info-websocket-after-metadata

Conversation

@yutianjiang39

Copy link
Copy Markdown

Info.__init__ starts the WebSocket manager before loading metadata. If spot_meta() raises, construction fails: the caller never receives an Info instance on which to call disconnect_websocket(). In an offline reproduction against 2fdb18f, the real manager thread was still alive after the exception and the fake transport had not been closed.

Move manager creation and startup to the end of metadata initialization. A metadata error still propagates, but there is no background WebSocket to clean up. Successful construction still starts the manager once when skip_ws is false. This change does not alter reconnect or subscription handling.

Regression tests: python -m pytest -o addopts= -q tests/info_websocket_init_test.py. The failure-path test forces spot_meta() to raise and checks that start() was never called. The success-path test supplies metadata locally and checks that start() was called once. On the original source the first test failed and the second passed; with this change both passed. Neither test opens a socket or relies on thread timing.

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