apify / apify-ts

Crawlee dev repo
https://crawlee.dev
Apache License 2.0
22 stars 3 forks source link

chore: await all event listener executions before exiting #153

Closed vladfrangu closed 2 years ago

vladfrangu commented 2 years ago

To achieve this in the cleanest way possible (and to also make this usable by anyone who might need this), I took the EventEmitter interface from nodejs, replicated it in more modern code, added support for awaiting the execution of all listeners, and made it its own module.

There's no difference otherwise. The code does (almost) the exact same things the nodejs core code does (bar the catch handling for promises: the rejections will always be handled and emitted as error events).