preventDefault does not work for unhandledrejection event
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
People
(Reporter: evilpie, Unassigned)
References
()
Details
Attachments
(1 file)
324 bytes,
text/html
|
Details |
It seems like the code add for dispatching unhandledrejection
events intentionally ignores preventDefault
and will always trigger a error message in the console: https://searchfox.org/mozilla-central/rev/d9d492eda787a6eda66016e6f8398ee759f7bc25/xpcom/base/CycleCollectedJSContext.cpp#709-710
Chrome will however prevent logging when preventDefault()
is called in the event handler.
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Comment 2•4 years ago
|
||
The error message in the console is from https://searchfox.org/mozilla-central/rev/0e09b9191c02097034e46b193930f91c45b7885d/dom/promise/PromiseDebugging.cpp#277 and suppress if onLeftUncaught
callback of UncaughtRejectionObserver returns true. Right now UncaughtRejectionObserver is handled independently with the unhandled event, there is no easy way to suppress the error from event.preventDefault()
. However, I could try to handle them together if possible, but after my other works.
Comment 4•1 year ago
|
||
can reproduce behavior on 112.0.2
. This break MDN's description:
Many environments (such as Node.js) report unhandled promise rejections to the console by default. You can prevent that from happening by adding a handler for unhandledrejection events that—in addition to any other tasks you wish to perform—calls preventDefault() to cancel the event, preventing it from bubbling up to be handled by the runtime's logging code.
And Chrome handles this correctly (as described by MDN).
I am on mac with firefox 124.0.2.
The bug is still reproductible. Any progress on this issue ?
Is there a workaround to this ?
I am using the unhandledrejection
event to call preventDefault()
on controlled exceptions. Still logging in the console
Description
•