Skip to content

Allow registering multiple uncaught exception capture callbacks #23348

@misterdjules

Description

@misterdjules

Is your feature request related to a problem? Please describe.

While experimenting with building a user-land alternative to the core domain module, I realized that the fact that one can only set one uncaught exception callback makes it more difficult than it could be.

Basically, the problem is that it is not possible to have two different implementations of a "domain-like" module loaded at the same time in a given process. For instance, it is currently not possible to load the user-land domaine module along with the core domain module.

This makes it difficult for applications to start adopting user-land alternatives to domain: in the current state, they (and all their dependencies) either need to adopt one single user-land alternative, or stick with the core domain module.

A good example is when I ported restify to use this new domaine module instead of the core domain module. I had to port node-tap (which is used to run restify's tests) to use that new domaine module as well.

Another example is the fact that one cannot use a user-land domain-like module from within the core repl because it requires domain.

This is something that I started discussing with @addaleax but that I thought would benefit from being presented to a broader set of people to gather initial feedback, comments and suggestions.

Describe the solution you'd like

The fundamental change would be to allow multiple uncaught exception callbacks to be registered.
I haven't thought too much about the design or the implementation details of a specific solution. I'd first like to gather feedback on whether people would be open to allowing multiple callbacks to be registered.

Describe alternatives you've considered

The only alternative to having this feature available that I can see for now is to require applications to migrate their code and all their dependencies to any user-land domain module that they choose to use.

Looking forward to reading your thoughts!

/cc @addaleax @vdeturckheim @nodejs/domains

Metadata

Metadata

Assignees

No one assigned

    Labels

    domainIssues and PRs related to the domain subsystem.feature requestIssues that request new features to be added to Node.js.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions