- From: Adam Rice <notifications@github.com>
- Date: Thu, 09 Feb 2017 23:53:01 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/675/278879979@github.com>
I found an assertion failure:
```javascript
promise_test(() => {
let writer;
const strategy = {
size() {
writer.close('C');
return 1;
}
};
const ws = recordingWritableStream({}, strategy);
writer = ws.getWriter();
return writer.write('W')
.then(() => {
assert_array_equals(ws.events, ['write', 'W', 'close', 'C'], 'close should happen after write');
});
}, 'close() should be work when called from within strategy.size()');
```
I get this output with the reference implementation:
```
whatwg/streams/reference-implementation/lib/utils.js:10
throw e;
^
AssertionError: queue must be empty once the final write record is dequeued
at WritableStreamDefaultControllerProcessClose (whatwg/streams/reference-implementation/lib/writable-stream.js:854:3)
at WritableStreamDefaultControllerAdvanceQueueIfNeeded (whatwg/streams/reference-implementation/lib/writable-stream.js:835:5)
at WritableStreamDefaultController.Promise.resolve.then (whatwg/streams/reference-implementation/lib/writable-stream.js:712:9)
```
I expected this test to pass. I did not spot the issue when I manually inspected the standard. There are so many code paths that it is difficult to have certainty that there are no issues.
I suggest we hoist the call to strategySize to be the very first thing in WritableStreamDefaultWriterWrite, before the state checks.The state checks that are currently in `write()` should be moved into WritableStreamDefaultWriterWrite so that they can happen after the call to strategySize. This would leave no way for strategySize to put us in a bad state.
You can see the rest of my work-in-progress tests at https://github.com/ricea/web-platform-tests/blob/9380b44bf34132e145be508d7a0847781e3b7a62/streams/writable-streams/reentrant-strategy.js.
--
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/675#issuecomment-278879979
Received on Friday, 10 February 2017 07:53:33 UTC