Bug 201005

Summary: [JSC] Prune about-to-be-notified rejected promises list at GC flip
Product: WebKit Reporter: Ross Kirsling <ross.kirsling>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: fpizlo, keith_miller
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ross Kirsling 2019-08-21 16:09:20 PDT
From bug 197172 comment 36:

> If you have a loop with:
> 
> let p = new Promise((resolve, reject) => {
>     ...
>     reject(p)
> });
>
> p will be kept alive until the the microtasks are drained. Which means programs will OOM if they never drain all their microtasks...
>
> I think, at least, you'll need to clear handled promises at the GC flip. See where we call finalizeUnconditionalFinalizers.

Given the WHATWG spec*, I don't believe this is something we can address for the normal, web-hosted case (i.e. the "unhandledrejection" event), but it would be a possible improvement for rejection tracking in a standalone JSContext (which has no spec).

[*] https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections