Attach connection errors to socket

Raising the errors would crash the current thread. As this thread
contains the Eventmachine, that would influence other connections
as well. Attaching the errors to the connection and reading them
after the connection was closed ensures that the thread stays
alive while handling the errors in the main thread of the current
request.
This commit is contained in:
Felix Auringer
2021-07-22 10:09:24 +02:00
committed by Sebastian Serth
parent c8e1a0bbcb
commit 9e2cff7558
5 changed files with 36 additions and 13 deletions

View File

@ -89,6 +89,7 @@ class Runner::Strategy::Poseidon < Runner::Strategy
websocket_url = execute_command(command)
socket = Connection.new(websocket_url, self, event_loop)
yield(socket)
socket
end
def destroy_at_management
@ -130,7 +131,8 @@ class Runner::Strategy::Poseidon < Runner::Strategy
def decode(raw_event)
JSON.parse(raw_event.data)
rescue JSON::ParserError => e
raise Runner::Error::UnexpectedResponse.new("The WebSocket message from Poseidon could not be decoded to JSON: #{e.inspect}")
@error = Runner::Error::UnexpectedResponse.new("The WebSocket message from Poseidon could not be decoded to JSON: #{e.inspect}")
close(:error)
end
def encode(data)