Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled AHD when uncaughtException / unhandledRejection listeners are installed #24

Open
Damaged-Organic opened this issue Aug 6, 2024 · 0 comments

Comments

@Damaged-Organic
Copy link

@Damaged-Organic In the future, please create new issues for new issues, rather than posting your new problem as a comment on an old issue. Otherwise, it's far more likely (in some cases, nearly guaranteed) that your problem will be overlooked, and even if it isn't, the solution will not be searchable by future users, and it will likely spam a bunch of other people who can't help you anyway.

AHD intentionally does not trigger the Domain error handler if you have a process.on('uncaughtException') handler, because it's only intended to handle cases that would crash the process. If you have your own handler that handles the error, then the error won't crash the process, so the domain should not trigger.

Originally posted by @isaacs in #23 (comment)

Sure. Thanks for your response. The issue I've mentioned might be unique for some use cases, but if it's a deliberate design choice, can you please explain why AHD supposed to work only in the case when there's no uncaughtException / unhandledRejection listeners already set (an error won't crash the process as you've mentioned)?

In my particular use case, I need to observe separate components of the application for errors. At the top level error handler, it is required to decide what to do with the component based on errors it might throw.

I understand that it is possible to do new Domain(...) at the application entry point to be that "root error handler", but I can't substitute regular process uncaughtException / unhandledRejection events with AHD if I don't have an access to the application root.

If anyone is constrained by some existing code and cannot change it, it becomes impossible to use this (AFAIK, the only decent substitute of the deprecated domain, which actually behaves as expected - throw on error becomes one of the process error events accordingly).

All I'm saying, would it really be a design/technical violation to include an additional behavior in the AHD API in form of the boolean flag which will keep Domains enabled even if the aforementioned process events are set, with error bubbling up accordingly?

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

No branches or pull requests

1 participant