Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Conversation

@grdsdev
Copy link

@grdsdev grdsdev commented Mar 31, 2025

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When an error is raised when sending a message through the socket it just gets logged

What is the new behavior?

Handle the raised error when sending a message and initiate the reconnect flow.

Additional context

Add any other context or screenshots.

@grdsdev grdsdev requested a review from Copilot March 31, 2025 17:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a reconnection issue when sending messages fails by updating the connection attribute usage and error handling. Key changes include:

  • Switching from the public ws_connection attribute to the internal _ws_connection in both connection logic and tests.
  • Introducing a new test case to validate reconnection behavior after a simulated connection failure.
  • Updating the pyproject.toml dev dependency configuration.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/test_connection.py Updated tests to reference _ws_connection and added reconnection test case
realtime/_async/client.py Replaced ws_connection with _ws_connection and adjusted error handling
pyproject.toml Reorganized dev dependency configuration under a new dependency group
Comments suppressed due to low confidence (1)

tests/test_connection.py:262

  • [nitpick] The test is directly accessing the protected attribute '_ws_connection'. Consider using a public interface (e.g., is_connected) or a dedicated getter to reduce coupling to internal implementation details.
initial_ws = socket._ws_connection

)

try:
await self._ws_connection.send(message)
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

In the send_message function, errors during message sending are caught and handled with _on_connect_error, but the caller is not informed of the failure. Consider propagating the exception after handling so that the failure is not silently suppressed.

Copilot uses AI. Check for mistakes.
aiohttp = "^3.11.14"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

The new dev dependency group only includes a subset of the dependencies previously defined. Please verify if the removal of dependencies like pytest, python-dotenv, pytest-asyncio, and coveralls is intentional.

Copilot uses AI. Check for mistakes.
@grdsdev grdsdev marked this pull request as ready for review March 31, 2025 17:06
@grdsdev grdsdev requested a review from silentworks March 31, 2025 17:06
@coveralls
Copy link

coveralls commented Mar 31, 2025

Pull Request Test Coverage Report for Build 14177115261

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+4.8%) to 83.8%

Totals Coverage Status
Change from base Build 14145452679: 4.8%
Covered Lines: 688
Relevant Lines: 821

💛 - Coveralls

@grdsdev grdsdev merged commit 8941d17 into main Apr 24, 2025
13 checks passed
@grdsdev grdsdev deleted the fix/reconnect-after-error-sending-mesage branch April 24, 2025 22:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants