Bug 224315

Summary: Throw within queueMicrotask callbacks are not reported
Product: WebKit Reporter: Xuan Huang <huxpro>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cdumez, keith_miller, mark.lam, m.goleb+bugzilla, msaboff, saam, smoley, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Safari 13 does nothing none

Description Xuan Huang 2021-04-07 19:29:49 PDT
Created attachment 425470 [details]
Safari 13 does nothing

Webkit does nothing if a callback queued via `queueMicrotask` throw.

The spec (https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing) specified:

> The queueMicrotask(callback) method must queue a microtask to invoke callback, and if callback throws an exception, report the exception.

The expected behavior is similar to `throw` within `setTimeout` callback.
Comment 1 Xuan Huang 2021-04-07 20:51:00 PDT
I first tested in in Safari 13 but now I tried with technology preview and it's the same.

I'm not sure how to fix this though. As far as I know, JavaScriptCore automatically drains its internal microtask queue when JSLock is released. I'm not sure how would exceptions thrown during the draining can propagate to WebCore.
Comment 2 Radar WebKit Bug Importer 2021-04-08 15:05:27 PDT
<rdar://problem/76423585>