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

Regular CI failures with Could not bind to 'host:port' #15492

Open
ysbaddaden opened this issue Feb 20, 2025 · 1 comment
Open

Regular CI failures with Could not bind to 'host:port' #15492

ysbaddaden opened this issue Feb 20, 2025 · 1 comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:specs topic:stdlib:networking

Comments

@ysbaddaden
Copy link
Contributor

The socket related specs (TCP, HTTP, ...) regularly fail on CI with a Could not bind to host:port exception.

These don't happen much on Linux, but they happen frequently enough on Windows that they got annoying and a waste of time to figure out it's unimportant and re-running the failed job(s).

@ysbaddaden
Copy link
Contributor Author

I'm suspicious of the unused_local_port helper method. It starts a TCP server on port 0, grabs the actual port number, closes the TCP server and returns the port number.

Specs then go on to immediately start a server on that port.

I believe closing the socket on the port doesn't necessarily happen fast enough in the system (or asynchronously), so when we try to bind a new socket on the port, that fails.

Whenever possible we should instead start the server on port 0 and use server.port if we need to connect a client to that port, as we do this in a few places already.

If there are cases where we can't do the above, then we might want to introduce a retry mechanism, with some delay, before failing after a few attempts.

@ysbaddaden ysbaddaden added good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:specs labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:specs topic:stdlib:networking
Projects
None yet
Development

No branches or pull requests

2 participants