diff --git a/lib/runner/connection.rb b/lib/runner/connection.rb index 5619bf2d..03368ab7 100644 --- a/lib/runner/connection.rb +++ b/lib/runner/connection.rb @@ -112,7 +112,7 @@ class Runner::Connection def on_close(_event) Rails.logger.debug { "#{Time.zone.now.getutc}: Closing connection to #{@socket.url} with status: #{@status}" } - forward_message @buffer.flush + forward_message @buffer.flush unless @buffer.empty? # Depending on the status, we might want to destroy the runner at management. # This ensures we get a new runner on the next request. diff --git a/lib/runner/connection/buffer.rb b/lib/runner/connection/buffer.rb index 82dc1006..c7dcba87 100644 --- a/lib/runner/connection/buffer.rb +++ b/lib/runner/connection/buffer.rb @@ -38,6 +38,10 @@ class Runner::Connection::Buffer remaining_buffer end + def empty? + @line_buffer.empty? && @global_buffer.empty? + end + private def process_and_split(message_parts, stop: false)