Fixes CODEOCEAN-5J with error during WebSocket handshake

This commit is contained in:
Sebastian Serth
2021-11-18 13:55:47 +01:00
parent 4cddcb6544
commit c90e02e4f1

View File

@ -20,7 +20,7 @@ class Runner::Connection
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Opening connection to #{url}" } Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Opening connection to #{url}" }
@socket = Faye::WebSocket::Client.new(url, [], strategy.class.websocket_header) @socket = Faye::WebSocket::Client.new(url, [], strategy.class.websocket_header)
@strategy = strategy @strategy = strategy
@status = :established @status = :new
@event_loop = event_loop @event_loop = event_loop
@locale = locale @locale = locale
@stdout_buffer = Buffer.new @stdout_buffer = Buffer.new
@ -115,14 +115,15 @@ class Runner::Connection
def on_open(_event) def on_open(_event)
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Established connection to #{@socket.url}" } Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Established connection to #{@socket.url}" }
@status = :established
@start_callback.call @start_callback.call
end end
def on_error(event) def on_error(event)
# In case of an WebSocket error, the connection will be closed by Faye::WebSocket::Client automatically. # In case of an WebSocket error, the connection will be closed by Faye::WebSocket::Client automatically.
# Thus, no further handling is required here (the user will get notified). # Thus, no further handling is required here (the user will get notified).
Sentry.set_extras(event: event.inspect) @status = :error
Sentry.capture_message("The WebSocket connection to #{@socket.url} was closed with an error.") @error = Runner::Error::Unknown.new("The WebSocket connection to #{@socket.url} was closed with an error: #{event.message}")
end end
def on_close(_event) def on_close(_event)