TCPSocket specs hang if client doesn't connect

Open
#925 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby

Research direction

Read the TCPSocket fixture in library/socket/fixtures/classes.rb around lines 125-129, focusing on the server shutdown and the Thread#join. Run the TCPSocket#initialize specs with a client that fails to connect, then verify that closing the server before joining prevents the suite from hanging and handles any double-close error.

Written by the indexing model from the issue text.

Description

The TCPSocket#initialize specs will hang if the client socket does not connect to the server, since the shutdown for the server expects that it will have handled a request and be wrapping up here:

https://github.com/ruby/spec/blob/master/library/socket/fixtures/classes.rb#L125-L129

I found this while adding support for the new connect_timeout keyword; we do not support hash arguments on TCPSocket#initialize at the moment, so the socket never connects. This leaves the server waiting for an incoming connection, and the Thread#join above will hang the suite.

Perhaps we should actively try to close the server socket before we join the thread, and ignore any errors on the thread from a double-close? It would allow these specs to be a bit more robust when there are errors setting up the TCPSocket before connection.

Dominant language
Ruby
Stars
623
Forks
403
Avg merge
10h 38m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/spec

All issues in ruby/spec

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.