- From: Mattias Buelens <notifications@github.com>
- Date: Mon, 06 Jun 2022 08:39:33 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 6 June 2022 15:39:46 UTC
> * _cancelAlgorithm_ calls `return()` with the given cancel _reason_, whereas `IteratorClose` calls it with no arguments. It turns out that `return()` is only ever called _with_ an argument in the context of [`yield *` inside (async) generator functions](https://tc39.es/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation)... 🤔 So I suppose it makes more sense to leave it out, and align closer to `for..await.of` semantics? Hmmm... but if we removed the argument for `return()`, then we'd no longer have `ReadableStream.from` as the "reverse" of `ReadableStream.prototype.values` (see https://github.com/whatwg/streams/pull/1083#discussion_r598005739), because the cancel reason would no longer be propagated. 😕 ```javascript let rs1 = new ReadableStream({ cancel(reason) { console.log(reason) } }); let rs2 = ReadableStream.from(rs1); rs2.cancel("boom!"); // -> rs1 gets cancelled with `undefined` (should have been "boom!") -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/1083#issuecomment-1147591568 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/pull/1083/c1147591568@github.com>
Received on Monday, 6 June 2022 15:39:46 UTC