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

  Changed paths:
    A JSTests/stress/async-from-sync-iterator-done-rejected-no-close.js
    M Source/JavaScriptCore/runtime/JSMicrotask.cpp

  Log Message:
  -----------
  [JSC] `AsyncFromSyncIterator` should not close the sync iterator for a 
rejected value when done is true
https://bugs.webkit.org/show_bug.cgi?id=319585

Reviewed by Yusuke Suzuki.

317012@main made asyncFromSyncIteratorContinueOrDone close the sync iterator
when the awaited "value" of an iterator result is a rejected promise, but it
did so regardless of `done`. AsyncFromSyncIteratorContinuation[1] step 12 sets
onRejected to undefined when done is true, since a finished iterator has
nothing to close, so JSC ran `return` in a case where the spec (and V8) do not.

    let returnCount = 0;
    const it = { [Symbol.iterator]: () => ({
        next: () => ({ value: Promise.reject(new Error), done: true }),
        return() { returnCount++; return {}; }
    }) };
    (async () => { try { for await (const _ of it) {} } catch {} })();
    // JSC: returnCount === 1, expected 0

Only close the iterator on the rejected path when the microtask carries a
done: false result. closeOnRejection === false 
(%AsyncFromSyncIteratorPrototype%.return)
is already handled by the builtin passing @undefined as the sync iterator.

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

Test: JSTests/stress/async-from-sync-iterator-done-rejected-no-close.js

* JSTests/stress/async-from-sync-iterator-done-rejected-no-close.js: Added.
(shouldBe):
(makeIterable):
(async test):
(test.then):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::asyncFromSyncIteratorContinueOrDone):

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



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

Reply via email to