Skip to content

Commit

Permalink
Normative: Close sync iterator when async wrapper yields rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Dec 17, 2021
1 parent 012af13 commit 92262e3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -42957,7 +42957,7 @@ <h1>%AsyncFromSyncIteratorPrototype%.next ( [ _value_ ] )</h1>
1. Else,
1. Let _result_ be IteratorNext(_syncIteratorRecord_).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_, _syncIteratorRecord_, *true*).
</emu-alg>
</emu-clause>

Expand All @@ -42983,7 +42983,7 @@ <h1>%AsyncFromSyncIteratorPrototype%.return ( [ _value_ ] )</h1>
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_, _syncIteratorRecord_, *false*).
</emu-alg>
</emu-clause>

Expand All @@ -43009,7 +43009,7 @@ <h1>%AsyncFromSyncIteratorPrototype%.throw ( [ _value_ ] )</h1>
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_, _syncIteratorRecord_, *false*).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -43046,6 +43046,8 @@ <h1>
AsyncFromSyncIteratorContinuation (
_result_: unknown,
_promiseCapability_: a PromiseCapability Record,
_syncIteratorRecord_: unknown,
_closeIteratorOnRejection_: a Boolean,
)
</h1>
<dl class="header">
Expand All @@ -43062,7 +43064,14 @@ <h1>
1. Return ! CreateIterResultObject(_value_, _done_).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_unwrap_, 1, *""*, &laquo; &raquo;).
1. NOTE: _onFulfilled_ is used when processing the *"value"* property of an IteratorResult object in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object.
1. Perform ! PerformPromiseThen(_valueWrapper_, _onFulfilled_, *undefined*, _promiseCapability_).
1. If _closeIteratorOnRejection_ is *false*, then
1. Let _onRejected_ be *undefined*.
1. Else,
1. Let _closeIterator_ be a new Abstract Closure with parameters (_error_) that captures _syncIteratorRecord_ and performs the following steps when called:
1. Return ? IteratorClose(_syncIteratorRecord_, ThrowCompletion(_error_)).
1. Let _onRejected_ be ! CreateBuiltinFunction(_closeIterator_, 1, *""*, &laquo; &raquo;).
1. NOTE: _onRejected_ is used to close the Iterator when the *"value"* property of an IteratorResult object it yields is a rejected promise.
1. Perform ! PerformPromiseThen(_valueWrapper_, _onFulfilled_, _onRejected_, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 92262e3

Please sign in to comment.