Skip to content

[JSC] AsyncFromSyncIterator should close its sync-iterator when throw is null or undefined - #39876

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/asyncfromsynciterator-return
Feb 3, 2025
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/asyncfromsynciterator-return

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Feb 2, 2025

Copy link
Copy Markdown
Member

72c371a

[JSC] `AsyncFromSyncIterator` should close its sync-iterator when `throw` is null or undefined
https://bugs.webkit.org/show_bug.cgi?id=286885

Reviewed by Yusuke Suzuki.

The normative change for `AsyncFromSyncIterator`[1] includes the following two changes:

1. AsyncFromSyncIterator now closes the sync iterator when `throw` is called on the
wrapper but is not implemented on the sync iterator. In that case, it updates the
rejection value to a `TypeError` to reflect the contract violation.
2. AsyncFromSyncIterator closes its sync iterator when the sync iterator yields a
rejected promise as its value.

This normative change has already been implemented in V8[2]. This patch changes to
implement only the first change.

[1]: tc39/ecma262#2600
[2]: v8/v8@6c3f7aa#diff-c18e5d5743326f6ba544801f6ce25154b785f759885651f98924d5b56dc1c2e6

* JSTests/stress/async-from-sync-iterator-prototype-throw-close-sync-iter.js: Added.
(shouldBe):
(shouldThrowAsync):
(throw.new.Error.const.syncIterator.get throw):
(throw.new.Error.const.asyncIterator):
(throw.new.Error.async OurError):
(throw.new.Error):
(const.syncIterator.get throw):
(throw.new.Error.async drainMicrotasks):
(const.asyncIterator):
(async OurError):
(OurError):
(NotOurError):
(const.syncIterator.get return):
(async drainMicrotasks):
(async asyncIterator):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/builtins/AsyncFromSyncIteratorPrototype.js:
(throw):

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

6224ecd

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@sosukesuzuki
sosukesuzuki requested a review from a team as a code owner February 2, 2025 16:43
@sosukesuzuki sosukesuzuki self-assigned this Feb 2, 2025
@sosukesuzuki sosukesuzuki added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Feb 2, 2025
@sosukesuzuki sosukesuzuki added the merge-queue Applied to send a pull request to merge-queue label Feb 3, 2025
…row` is null or undefined

https://bugs.webkit.org/show_bug.cgi?id=286885

Reviewed by Yusuke Suzuki.

The normative change for `AsyncFromSyncIterator`[1] includes the following two changes:

1. AsyncFromSyncIterator now closes the sync iterator when `throw` is called on the
wrapper but is not implemented on the sync iterator. In that case, it updates the
rejection value to a `TypeError` to reflect the contract violation.
2. AsyncFromSyncIterator closes its sync iterator when the sync iterator yields a
rejected promise as its value.

This normative change has already been implemented in V8[2]. This patch changes to
implement only the first change.

[1]: tc39/ecma262#2600
[2]: v8/v8@6c3f7aa#diff-c18e5d5743326f6ba544801f6ce25154b785f759885651f98924d5b56dc1c2e6

* JSTests/stress/async-from-sync-iterator-prototype-throw-close-sync-iter.js: Added.
(shouldBe):
(shouldThrowAsync):
(throw.new.Error.const.syncIterator.get throw):
(throw.new.Error.const.asyncIterator):
(throw.new.Error.async OurError):
(throw.new.Error):
(const.syncIterator.get throw):
(throw.new.Error.async drainMicrotasks):
(const.asyncIterator):
(async OurError):
(OurError):
(NotOurError):
(const.syncIterator.get return):
(async drainMicrotasks):
(async asyncIterator):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/builtins/AsyncFromSyncIteratorPrototype.js:
(throw):

Canonical link: https://commits.webkit.org/289726@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/asyncfromsynciterator-return branch from 6224ecd to 72c371a Compare February 3, 2025 11:05
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 289726@main (72c371a): https://commits.webkit.org/289726@main

Reviewed commits have been landed. Closing PR #39876 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants