composablesys / collabs

Collabs library monorepo

Home Page:https://collabs.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle errors in event emitters

mweidner037 opened this issue · comments

Currently, EventEmitter traps any errors emitted by an event handler, merely logging them to console.error. We should consider letting these errors just propagate normally. That way, errors caused by local ops (including parent CRDT logic in an event listener) propagate immediately and prevent a message from being sent, and mocha can see these errors during tests.

My concern is that an error in an "irrelevant" event handler will then interfere with the other handlers and the event emitter. But perhaps this is not really an issue, especially since events are often handled at most once (either by the parent CRDT or by the GUI component rendering the CRDT). And you can always "opt out" using a top level try-catch in your own event handlers.

Can also clarify related error messages. E.g. "did you try to perform an operation in an event handler?": could also be from a message in a Collab constructor or valueConstructor callback.

It would also be nice to throw an error if you send a message during a registerCollab callback.

Including CRuntime events