fix: do not crash the event emitting parent process if on listener fails #52799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves
Currently when a miss behaving event listener errors with out proper error catching this causes the emitting process to error also.
The issue here is that at this causes data loss and loss of functionality in unrelated apps. For instance, when saving a Calendar Appointment we emit a create calendar object event for every attendee that the event is saved to.
E.g.
Attendee 1 (Save Object) -> Emit Event ->Attendee 2 (Save Object) -> Emit Event -> Organizer (Save Object) -> Emit Event
So when a event listener errors after the first emit the entire process crashes and we lose data, even though the emitting process experienced no errors. As event listeners can be implemented by any app, there is no way to make sure that the code being executes is safe.
Some example of recent issues that causes user confusion and data loss..
Constructor errors
TypeError: OCA\Talk\Listener\CalDavEventListener::__construct(): Argument #6 ($userId) must be of type string, null given
#26 /spreed/lib/Listener/CalDavEventListener.php(32): OCA\Talk\Listener\CalDavEventListener::__construct
Runtime errors
ErrorException: Warning: Attempt to read property "LOCATION" on null
#17 /spreed/lib/Listener/CalDavEventListener.php(68): OCA\Talk\Listener\CalDavEventListener::handle
Summary
Checklist