Skip to content

Commit

Permalink
Also close the WebSocket when we close the session
Browse files Browse the repository at this point in the history
When we're closing sessions, we do not close the WebSocket and instead
kinda rely on the server kicking us out due to inactivity. This makes
it racy for cases like connection retries (which we have disabled and
instead close any previous sessions), where we can have two concurrent
connections for the same session id. An invariant violation!

This change now also makes sure to close the WebSocket when the session
is closed.
  • Loading branch information
lhchavez committed Jul 19, 2024
1 parent a511268 commit e868b67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name="replit-river"
version="0.2.19"
version="0.2.20"
description="Replit river toolkit for Python"
authors = ["Replit <eng@replit.com>"]
license = "LICENSE"
Expand Down
1 change: 1 addition & 0 deletions replit_river/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,5 @@ async def close(self) -> None:
stream.close()
async with self._stream_lock:
self._streams.clear()
await self.close_websocket(self._ws_wrapper, should_retry=False)
self._state = SessionState.CLOSED

0 comments on commit e868b67

Please sign in to comment.