Skip to content

Pass promise argument to Promise._unhandledRejectionFn#168

Open
MattiasBuelens wants to merge 3 commits intotaylorhakes:masterfrom
MattiasBuelens:unhandledrejectionfn-promise
Open

Pass promise argument to Promise._unhandledRejectionFn#168
MattiasBuelens wants to merge 3 commits intotaylorhakes:masterfrom
MattiasBuelens:unhandledrejectionfn-promise

Conversation

@MattiasBuelens
Copy link

Currently, Promise._unhandledRejectionFn only receives the rejection reason err. However, in order to implement a "faithful" replica of the global unhandledrejection event, this also needs to receive the unhandled Promise itself.

This adds the promise as a second argument for Promise._unhandledRejectionFn. The default implementation doesn't use this argument, but users could replace it with their own version, for example:

Promise._unhandledRejectionFn = function(reason, promise) {
  globalThis.dispatchEvent(new PromiseRejectionEvent('unhandledrejection', { reason, promise }));
};

@MattiasBuelens MattiasBuelens force-pushed the unhandledrejectionfn-promise branch from e578dc7 to 65c6480 Compare January 30, 2026 16:58
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.

1 participant