Skip to content

Consider exposing promise unhandled rejection hook #256

Closed
@benjamingr

Description

Promise unhandled rejection

It is common for promise libraries to emit possibly unhandled rejections (promise chains no .catch listener or then with a second argument is attached to).

Most libraries as well as native promises in V8 support detecting these cases.

It is common for code to have multiple promise libraries, native promises and multiple copies of the same promise library included. Sometimes people are interested in hook on such unhandled rejections in order to add custom logging, terminate the process, suppress the rejection etc. - a survey (in the later linked gist) indicates that this is used in practice by users.

What I'm asking for

I'm asking for native promises to emit events on possibly unhandled rejections so that user level code can handle them to provide better debugging.

Here is the actual proposal

It is currently in the seeking feedback stage.

Effect on user APIs

None, there is no resource penalty, API changes or backwards incompatible changes introduced by this.

Implementation in userland

Since this change requires talking to the native V8 promise implementation which in turn cannot implement this itself since it is unaware of io, there is no possibility to implement this at a user level either because the hooks are not exposed.

Non native promises (promise libraries) will implement it at a userlevel but since people are writing code that depends on native promises and they are a language feature this hook is required.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions