Skip to content

Conversation

@vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Sep 25, 2020

For some scenarios, if a user error in a libp2p event handler is thrown, the handler execution fails silently and the user has no way of knowing about the error.

The best solution according to the EventEmitter docs is to throw all the side effects of the emit in the global context, as it happens in node.js out of the box. Several browser shims for the EventEmitter I looked into leave this to the user and do not throw in the global context. Examples:

As JS has a variety of shims for each building tool, it is not feasible to fix this upstream. I created proper-event-emitter that extends Event Emitter and wraps the super.emit with a try catch and throw it in the global context using setTimeout

Closes #751

@vasco-santos vasco-santos force-pushed the fix/event-handlers-error branch 5 times, most recently from 3915171 to 326035a Compare September 29, 2020 08:10
@vasco-santos vasco-santos marked this pull request as ready for review September 29, 2020 08:36
@vasco-santos vasco-santos force-pushed the fix/event-handlers-error branch from 326035a to 4c1b376 Compare October 7, 2020 16:26
@vasco-santos vasco-santos mentioned this pull request Nov 25, 2020
1 task
@vasco-santos vasco-santos mentioned this pull request Dec 10, 2020
7 tasks
@achingbrain
Copy link
Member

Closing due to staleness

@achingbrain achingbrain deleted the fix/event-handlers-error branch April 18, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libp2p.on() silently eats errors/exceptions

3 participants