NEW216149
Promises created from async functions don't resolve when document is detached.
https://bugs.webkit.org/show_bug.cgi?id=216149
Summary Promises created from async functions don't resolve when document is detached.
John-David Dalton
Reported 2020-09-03 15:27:10 PDT
The following snippet works in Chrome: (async () => { var i = document.createElement('iframe'); document.body.appendChild(i); var a = i.contentWindow.eval('(async () => await 1)'); i.remove(); // someone removes the iframe const v = await a(); console.log(v); })(); Our use case has code that works when wired up and then someone removes the iframe and `await` no longer resolves.
Attachments
Radar WebKit Bug Importer
Comment 1 2020-09-04 14:56:44 PDT
Emilio Cobos Álvarez (:emilio)
Comment 2 2020-09-06 09:00:30 PDT
This might be a Chrome bug per spec, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c3 (Though I haven't double-checked)
Yusuke Suzuki
Comment 3 2020-09-09 10:19:01 PDT
Currently, what we should do is not fully clarified in the spec. It is ongoing discussion. But I think forever-pending promise would make sense since we should stop execution of script, and rejecting promise can involve script execution. https://github.com/whatwg/html/issues/2621
Tooru Fujisawa [:arai]
Comment 4 2025-06-02 03:22:39 PDT
With the latest Safari Technology Preview (Release 220 (Safari 18.4, WebKit 20622.1.14.5)), the equivalent testcase now logs "1" https://bug1663090.bmoattachments.org/attachment.cgi?id=9174036 Was there any change around how the promise reaction jobs in detached iframe works? I'd like to see when and how the behavior changed. Regarding the spec, it looks like there were a bunch of changes around how iframe and related conditions are defined, but I cannot locate any semantic change that affects the jobs in detached iframes, and to my understanding the expected behavior is still "the promise reaction job in the testcase is never called". https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c16 https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c17
Tooru Fujisawa [:arai]
Comment 5 2025-06-19 20:58:05 PDT
So it turns out this is causing inter-op issue as mentioned in https://github.com/whatwg/html/issues/11252 . A WPT testcase for the behavior is going to be added in https://bugzilla.mozilla.org/show_bug.cgi?id=1972990 . The testcase fails on Safari/WebKit because those promise reaction/thenable jobs in detached iframe gets executed, while the global is considered to be not-fully-active.
Note You need to log in before you can comment on or make changes to this bug.