Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure WebSocket is always marked as closed after getting ConnectionClosed error #132

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cbrewster
Copy link
Member

Why

When we received a ConnectionClosed error while reading from the WebSocket, we were not marking the ws_wrapper as closed. This meant that the reconnection code thought that there was already an open WebSocket connection and did not attempt reconnection. Leaving the session stuck until the grace period elapses.

What changed

  • Always call close_websocket after getting a ConnectionClosed error so that the bookkeeping is up to date
    • This unifies some of the codepaths so we perform the same logic no matter where the disconnect error happens
    • Also renamed _handle_connection_closed so its more clear
  • close_websocket also handles triggering a reconnect, if enabled

Test plan

  • TBD

@cbrewster
Copy link
Member Author

Current dependencies on/for this PR:

This comment was autogenerated by Freephite.

)

await self._begin_close_session_countdown()
await self._handle_connection_closed()
Copy link
Member

Choose a reason for hiding this comment

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

seems like we lost the _retry_connection_callback callback here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is already handled down inside close_websocket:

if should_retry and self._retry_connection_callback:
self._task_manager.create_task(self._retry_connection_callback())

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.

2 participants