Skip to content

Commit

Permalink
When underlyingSink.close() fulfills, assert state
Browse files Browse the repository at this point in the history
Previously, WritableStreamDefaultControllerProcessClose checked the state was "closing" or "errored" when underlyingSink.close() fulfills. In fact it can't be anything else, so make it an assert instead.
  • Loading branch information
ricea authored and domenic committed Jan 6, 2017
1 parent 22b3f03 commit fc065d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3405,7 +3405,7 @@ nothrow>WritableStreamDefaultControllerProcessClose ( <var>controller</var> )</h
1. <a>Upon fulfillment</a> of _sinkClosePromise_,
1. Assert: _controller_.[[inClose]] is *true*.
1. Set _controller_.[[inClose]] to *false*.
1. If _stream_.[[state]] is not `"closing"` or `"errored"`, return.
1. Assert: _stream_.[[state]] is `"closing"` or `"errored"`.
1. Assert: _stream_.[[pendingCloseRequest]] is not *undefined*.
1. <a>Resolve</a> _stream_.[[pendingCloseRequest]] with *undefined*.
1. Set _stream_.[[pendingCloseRequest]] to *undefined*.
Expand Down
5 changes: 1 addition & 4 deletions reference-implementation/lib/writable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,7 @@ function WritableStreamDefaultControllerProcessClose(controller) {
() => {
assert(controller._inClose === true);
controller._inClose = false;
if (stream._state !== 'closing' && stream._state !== 'errored') {
return;
}

assert(stream._state === 'closing' || stream._state === 'errored');
assert(stream._pendingCloseRequest !== undefined);
stream._pendingCloseRequest._resolve(undefined);
stream._pendingCloseRequest = undefined;
Expand Down

0 comments on commit fc065d1

Please sign in to comment.