envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Gracefully handle terminating subprocesses #223

Closed orien closed 3 years ago

orien commented 3 years ago

It has been found that the ESPRunner class would fail when notified of a terminated process it didn't start.

NoMethodError: undefined method `processor_name' for nil:NilClass
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:110:in `record_terminated_processes'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:30:in `block (2 levels) in start!'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:82:in `block in while_waiting_for_shutdown'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:81:in `loop'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:81:in `while_waiting_for_shutdown'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:29:in `block in start!'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:66:in `with_logging'
/usr/local/bundle/gems/event_sourcery-0.23.0/lib/event_sourcery/event_processing/esp_runner.rb:26:in `start!'

Gracefully handle this situation by ignoring these notifications.

orien commented 3 years ago

@scottyp-env yeah, I'm curious to. Another possibility is subprocesses started by the main process before starting the ESPRunner.