[whatwg/streams] Refactor writable stream erroring to be centralized (#705)

@ricea's work in #704 got me thinking: why don't we ResetQueue() *every* time we error a writable stream?

In fact it seems like we have many different code paths for erroring a writable stream, some of which behave slightly differently. You can see me evolving them toward convergence in the sequential commits here, eventually ending up with a bunch of duplicated code which all gets factored into the single WritableStreamError abstract op.

There were two reasons that the erroring code was so different in different places:
- Often we omitted steps that were not necessary in a given scenario, which hid the underlying same-ness of the erroring operation.
- We decided that abort()ing during an in-flight close should error the stream. This was not a good idea: it was unlike every other erroring we did. And we recognized that it was weird, because we made abort() return a fulfilled promise. Instead we should treat this as a success and close the stream, both for the return value of abort() and for the stream's state.

This PR has a few minor issues which I will note in inline comments. It only updates the reference implementation for now, as well as the tests; it does not update the spec yet.
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/705

-- Commit Summary --

  * Factor out some of the erroring code
  * Make code more duplicated near erroring code
  * Make it even more duplicated. This requires small test changes.
  * Change the semantics of aborting during close
  * OK now everything's basically working
  * Tweak order
  * Update tests inline for now

-- File Changes --

    M reference-implementation/lib/writable-stream.js (127)
    M reference-implementation/web-platform-tests (2)

-- Patch Links --

https://github.com/whatwg/streams/pull/705.patch
https://github.com/whatwg/streams/pull/705.diff

-- 
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/pull/705

Received on Friday, 24 March 2017 10:02:16 UTC