Skip to content

Close reserved sockets before testing connection failures - #910

Open
gauravch-code wants to merge 1 commit into
elevenlabs:mainfrom
gauravch-code:fix/macos-connection-failure-tests
Open

gauravch-code wants to merge 1 commit into
elevenlabs:mainfrom
gauravch-code:fix/macos-connection-failure-tests

Conversation

@gauravch-code

Copy link
Copy Markdown
Contributor
Follow-up to #907, addressing @kraenhansen’s [request](https://github.com/elevenlabs/elevenlabs-python/pull/907#issuecomment-6436661396).

Close the temporary sockets after reading their ports, before attempting the connections. Keeping them bound but non-listening can cause the connection-failure tests to time out on macOS instead of receiving a refused connection.

This is a two-line, test-only change. SDK behavior and existing assertions are unchanged.

### Validation

- All 108 related tests pass on Python 3.8 and 3.13 on Windows.
- Ruff lint and whitespace checks pass.
- Native macOS verification is still needed.
- An existing formatting issue elsewhere in the test file is left unchanged.

@cursor

cursor Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only change with no production code or assertion updates.

Overview
Test fix for connection-failure scenarios on macOS — follow-up to #907.

In test_sync_connection_failure_reports_error and test_async_connection_failure_reports_error, the tests reserve an ephemeral port by binding a temporary socket, then close that socket before Conversation / AsyncConversation tries to connect. Previously the port stayed bound but nothing listened, which on macOS could make these tests hang until timeout instead of failing fast with a refused connection.

Assertions and SDK behavior are unchanged; this is a two-line, test-only reliability fix.

Reviewed by Cursor Bugbot for commit 43150a7. Bugbot is set up for automated code reviews on this repo. Configure here.

This branch has not been deployed

No deployments
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