[Webkit-unassigned] [Bug 196484] New: Web Inspector: fake value descriptors for promises add a catch handler, preventing "rejectionhandled" events from being fired

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 2 00:19:03 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=196484

            Bug ID: 196484
           Summary: Web Inspector: fake value descriptors for promises add
                    a catch handler, preventing "rejectionhandled" events
                    from being fired
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: All
                OS: All
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Inspector
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: drousso at apple.com
                CC: inspector-bugzilla-changes at group.apple.com

```
window.addEventListener("unhandledrejection", (event) => {
    console.log("unhandledrejection", event);
});

window.addEventListener("rejectionhandled", (event) => {
    console.log("rejectionhandled", event);
});

var promise = Promise.reject(42);

setTimeout(() => {
    promise.catch((x) => {
        console.log(x);
    });
}, 500);
```

Running that code with Web Inspector open will cause the following to be logged:
1
[Log] unhandledrejection – PromiseRejectionEvent { ... }
[Error] Unhandled Promise Rejection: 42
[Log] 42

There should also be a "[Log] rejectionhandled - PromiseRejectionEvent { ... }", but that doesn't get fired because when `InjectedScript` creates a fake value descriptor (since there is a native getter `PromiseRejectionEvent.prototype.get promise`), it adds a `catch` handler to the promise to prevent "The PromiseRejectionEvent.promise getter can only be used on instances of PromiseRejectionEvent" messages from being logged to the console.  Since this `catch` handler is added as a response to "unhandledrejection", it becomes handled and is therefore no longer kept track of to fire a "rejectionhandled" when a `catch` handler is added.

<https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections>

If the "unhandledrejection" event listener is removed (or the `event` value isn't logged to the console), the "rejectionhandled" event is fired as expected, because we don't generate a preview (which involves generating a fake value descriptor).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190402/a94a26e5/attachment-0001.html>


More information about the webkit-unassigned mailing list