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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout when connecting to server #708

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/spring/client/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ def stop_server
end

def verify_server_version
server_version = server.gets.chomp
unless IO.select([server], [], [], CONNECT_TIMEOUT)
Copy link
Member

Choose a reason for hiding this comment

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

So note that this only tell us there's something to read, it doesn't guarantee it's a whole line, so we can still potentially get stuck in server.gets.

However it should catch a large portion of such issues, so I think it's a good improvement.

raise "Error connecting to Spring server"
end

line = server.gets
unless line
raise "Error connecting to Spring server"
end

server_version = line.chomp
if server_version != env.version
$stderr.puts "There is a version mismatch between the Spring client " \
"(#{env.version}) and the server (#{server_version})."
Expand Down