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:

committed by
Sebastian Serth

parent
c8e1a0bbcb
commit
9e2cff7558
@ -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)
|
||||
|
Reference in New Issue
Block a user