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

Retry the Windows local pipe server connection once on EPIPE #694

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/train/transports/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,23 @@ def run_command(cmd, _opts)
script = "$ProgressPreference='SilentlyContinue';" + cmd
encoded_script = Base64.strict_encode64(script)
# TODO: no way to safely implement timeouts here.
@pipe.puts(encoded_script)
@pipe.flush
begin
@pipe.puts(encoded_script)
@pipe.flush
rescue Errno::EPIPE
# Retry once if the pipe went away
begin
# Maybe the pipe went away, but the server didn't? Reset it, to get a clean start.
close
rescue Errno::EIO
# Ignore - server already went away
end
@pipe = acquire_pipe
raise PipeError if @pipe.nil?

@pipe.puts(encoded_script)
@pipe.flush
end
res = OpenStruct.new(JSON.parse(Base64.decode64(@pipe.readline)))
Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
end
Expand Down