Re: [whatwg/streams] Execute strategySize first in write() (#680)

ricea commented on this pull request.



> @@ -654,7 +644,17 @@ function WritableStreamDefaultWriterRelease(writer) {
 function WritableStreamDefaultWriterWrite(writer, chunk) {
   const stream = writer._ownerWritableStream;
 
-  assert(stream !== undefined);
+  if (stream === undefined) {
+    return Promise.reject(defaultWriterLockException('write to'));
+  }
+
+  const controller = stream._writableStreamController;
+
+  const chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
+

Drive-by comment: maybe we should check that `stream === writer._ownerWritableStream` before proceeding?

strategySize might have
1. Detached the writer
2. Created a new writer and done a bunch of writes with it

It's probably better just to eliminate the possibility rather than try to work out whether it would be a problem or not.

Needs test(s).

-- 
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/680#pullrequestreview-21240324

Received on Friday, 10 February 2017 12:58:16 UTC