Bug 216149 - Promises created from async functions don't resolve when document is detached.
Summary: Promises created from async functions don't resolve when document is detached.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-03 15:27 PDT by John-David Dalton
Modified: 2020-09-09 10:19 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John-David Dalton 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.
Comment 1 Radar WebKit Bug Importer 2020-09-04 14:56:44 PDT
<rdar://problem/68367353>
Comment 2 Emilio Cobos Álvarez (:emilio) 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)
Comment 3 Yusuke Suzuki 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