Re: [whatwg/streams] # Handling Abrupt Completions in ReadableStreamDefaultControllerCallPullIfNeeded? (#1161)

`controller.[[pullAlgorithm]]` cannot return an abrupt completion.

[SetUpReadableStreamDefaultControllerFromUnderlyingSource](https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller-from-underlying-source) sets _pullAlgorithm_ to the result of [invoking](https://heycam.github.io/webidl/#invoke-a-callback-function) `underlyingSourceDict["pull"]`. Because the return type of [`UnderlyingSourcePullCallback`](https://streams.spec.whatwg.org/#callbackdef-underlyingsourcepullcallback) is `Promise<undefined>`, the WebIDL invoke algorithm will go through these steps:

> 14. Return: at this point _completion_ will be set to an ECMAScript completion value.
> 14.4. If _completion_ is an abrupt completion and the callback function has a return type that is not a promise type, return completion.
> 14.5. Let _rejectedPromise_ be ! Call(`%Promise.reject%`, `%Promise%`, «completion.[[Value]]»).
> 14.6. Return the result of converting _rejectedPromise_ to the callback function’s return type.

Indeed, previously we didn't use Web IDL for this, so we had a separate `PromiseCall` helper. But now we leverage Web IDL's conversion logic, and we expect implementers to conform to the Web IDL spec.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1161#issuecomment-902032645

Received on Thursday, 19 August 2021 15:58:26 UTC