content icon indicating copy to clipboard operation
content copied to clipboard

rejectionhandled event doesn't fire on every handled rejection, but only if unhandledrejection events was triggered

Open AnupamKhosla opened this issue 3 years ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event

What specific section or headline is this issue about?

https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event#basic_error_logging

What information was incorrect, unhelpful, or incomplete?

The rejectionhandled event doesn't always trigger. Have a look here https://stackoverflow.com/a/57261820/3429430 There should be a note:

The rejectionhandled event doesn't fire on every handled rejection, it only fires on rejections that were not handled at first (causing unhandledrejection events) but then did subsequently get a handler attached.

What did you expect to see?

rejectionhandled being fired or an explanation of why id doesn't fire.

Do you have any supporting links, references, or citations?

https://stackoverflow.com/a/57261820/3429430

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/window/unhandledrejection_event
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/window/unhandledrejection_event/index.md
  • Last commit: https://github.com/mdn/content/commit/f7dae62645a2c735ed6f6ed63f664bf279fdfc4b
  • Document last modified: 2022-09-09T05:19:45.000Z

AnupamKhosla avatar Nov 09 '22 04:11 AnupamKhosla

Thanks for raising this — I’ve opened #22182 with a change to address it.

What specific section or headline is this issue about?

developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event#basic_error_logging

That section is an example in the unhandledrejection page. The information in the issue description and the Stack Overflow question and answer are about the rejectionhandled event. So it’s not clear to me why or how that would fit into that example in the unhandledrejection page. Therefore the change I made in #22182 is to the https://developer.mozilla.org/en-US/docs/Web/API/Window/rejectionhandled_event page itself.

sideshowbarker avatar Nov 09 '22 08:11 sideshowbarker

@bsmth @sideshowbarker Hey guys, this info should also be added to the parent page "Using Promises"(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#promise_rejection_events).

Currently it says:

rejectionhandled Sent when a promise is rejected, after that rejection has been handled by the executor's reject function.

I'm not sure if sent and fire mean the same thing. IMO, It should explicitly mention that rejectionhandled is sent(fired?) only if unhandledrejection has been fired first.

AnupamKhosla avatar Dec 02 '22 07:12 AnupamKhosla

I suggest raising a new issue for that

sideshowbarker avatar Dec 02 '22 07:12 sideshowbarker