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
@@ -50,8 +50,9 @@ class Runner < ApplicationRecord
|
||||
# initializing its Runner::Connection with the given event loop. The Runner::Connection class ensures that
|
||||
# this event loop is stopped after the socket was closed.
|
||||
event_loop = Runner::EventLoop.new
|
||||
@strategy.attach_to_execution(command, event_loop, &block)
|
||||
socket = @strategy.attach_to_execution(command, event_loop, &block)
|
||||
event_loop.wait
|
||||
raise socket.error if socket.error.present?
|
||||
rescue Runner::Error => e
|
||||
e.execution_duration = Time.zone.now - starting_time
|
||||
raise
|
||||
|
Reference in New Issue
Block a user