Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8490d02c5dcc8461ce5d8161717d292d8085a596
      
https://github.com/WebKit/WebKit/commit/8490d02c5dcc8461ce5d8161717d292d8085a596
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-07-12 (Sun, 12 Jul 2026)

  Changed paths:
    A 
JSTests/stress/async-from-sync-iterator-close-on-rejection-throwing-return.js
    M Source/JavaScriptCore/runtime/JSMicrotask.cpp

  Log Message:
  -----------
  [JSC] AsyncFromSyncIterator does not close correctly when the sync iterator 
yields a rejected value promise
https://bugs.webkit.org/show_bug.cgi?id=319185

Reviewed by Yusuke Suzuki.

Per IteratorClose[1] invoked with a throw completion, any exception thrown
while getting or calling the return method must be discarded so the outer
completion (the original rejection reason) is preserved. JSC was letting a
throwing return() propagate (leaving the promise pending with an uncaught
exception) and letting a throwing return getter reject the promise with the
getter's exception instead of the original reason.

    const it = {
        [Symbol.iterator]: () => ({
            next: () => ({ value: Promise.reject(new Error("original")), done: 
false }),
            return() { throw new Error("close error"); }
        })
    };
    (async () => { for await (const _ of it) {} })(); // never settled before

[1]: https://tc39.es/ecma262/#sec-iteratorclose

Test: 
JSTests/stress/async-from-sync-iterator-close-on-rejection-throwing-return.js

* 
JSTests/stress/async-from-sync-iterator-close-on-rejection-throwing-return.js: 
Added.
(shouldBe):
(const.syncIterable.Symbol.iterator.return.get return):
(throw.new.Error.async drainMicrotasks):
(async drainMicrotasks):
(async gen):
(throw.new.Error):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::asyncFromSyncIteratorContinueOrDone):

Canonical link: https://commits.webkit.org/317012@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to