preventDefault does not work for unhandledrejection event
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | fixed |
People
(Reporter: evilpies, Assigned: jjaschke)
References
()
Details
Attachments
(2 files)
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•6 years ago
|
| Reporter | ||
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Comment 2•6 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•3 years 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
From https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections:
This algorithm results in promise rejections being marked as handled or not handled. These concepts parallel handled and not handled script errors. If a rejection is still not handled after this, then the rejection may be reported to a developer console.
Firefox ignores the standard and sends spam to the console.
Beyond the console spam which is annoying, this actively hinders automated testing: generally if an error bubbles up to the console / test runner it's a failure, here if the system makes use of preventDefault (generally specifically to test error paths) the test will fail on firefox, and requires significant alterations to the behaviour of the runner in order to work around the lack of a behaviour mozilla itself documents.
| Assignee | ||
Comment 10•3 months ago
|
||
Updated•3 months ago
|
Comment 11•3 months ago
|
||
Comment 12•3 months ago
|
||
Comment 13•3 months ago
|
||
Reverted this because it was causing devtools failures in browser_jsterm_await_error.js.
- Revert link
- Push with failures
- Failure Log
- Failure line: TEST-UNEXPECTED-FAIL | devtools/client/webconsole/test/browser/browser_jsterm_await_error.js | Test timed out
Comment 14•2 months ago
|
||
| Assignee | ||
Comment 15•2 months ago
|
||
Sorry for keeping you waiting for so long. I hope this works, if it doesn't please feel free to file a new bug and needinfo me. :)
Comment 16•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Description
•