Skip to content

refactor: remove unused async connect path and simplify response handling#42

Merged
jy-tan merged 1 commit intomainfrom
remove-async-connection
Jan 17, 2026
Merged

refactor: remove unused async connect path and simplify response handling#42
jy-tan merged 1 commit intomainfrom
remove-async-connection

Conversation

@jy-tan
Copy link
Copy Markdown
Contributor

@jy-tan jy-tan commented Jan 17, 2026

Summary

Removes dead code from ProtobufCommunicator which has potential issues with blocking the event loop and message multiplexing. The async connect() method and its helpers were never used because the SDK exclusively uses connect_sync().

Changes

Removed:

  • async def connect() - Unused async connection method with blocking socket calls inside an async function
  • async def _send_connect_message() - Helper only called by async connect
  • async def _receive_connect_response() - Helper only called by async connect
  • Dead "no background reader" branch in _receive_response() that used blocking socket reads and dropped non-matching messages (no multiplexing)

Modified:

  • disconnect() - Changed from async to sync since it only calls _cleanup()
  • _receive_response() - Simplified to always delegate to _wait_for_response_async() via the background reader thread
  • drift_sdk.py - Updated to call disconnect() directly instead of via asyncio.run()

Context

The removed async connect() path had two issues:

  1. Blocking socket reads in async function - Could stall the event loop
  2. No message multiplexing - Messages not matching the current request_id were silently discarded

These were latent bugs since the code path was never reached (connect_sync() is always used), and we probably won't need the async path, but removing them eliminates potential confusion and reduces maintenance burden.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@jy-tan jy-tan merged commit ac4a163 into main Jan 17, 2026
17 checks passed
@jy-tan jy-tan deleted the remove-async-connection branch January 17, 2026 02:33
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