whatwg / streams

Streams Standard
https://streams.spec.whatwg.org/
Other
1.35k stars 160 forks source link

"If flushPromise was rejected with reason r, the..." #1262

Open ricea opened 1 year ago

ricea commented 1 year ago

https://streams.spec.whatwg.org/commit-snapshots/b45c0c5a6c66c73c1e17254976e8a271aecc5592/#transform-stream-default-sink-close-algorithm

If flushPromise was rejected with reason r, then:​

Perform ! TransformStreamError(stream, r).

Throw readable.[[storedError]].

This may throw an undefined value if readable is closed when the microtask runs after flushPromise is rejected. Maybe we should do something like

  1. Let error be readable.[[storedError]] if readable.[[state]] is "errored", or r otherwise.
  2. Throw error.

What do you think?

domenic commented 1 year ago

I think I need more detail on the scenario you're envisioning. I guess there are two errors here, readable.[[storedError]] and r, and we need to decide which to throw? An example with the two errors being different values, and where the chosen value currently shows up, would be helpful.