Bug 215267

Summary: Refresh WritableStream up to spec
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, annulen, benjamin, calvaris, cdumez, esprehn+autocc, ews-watchlist, ggaren, gyuyoung.kim, joepeck, kondapallykalyan, ryuan.choi, sam, sergio, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 149842    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

youenn fablet
Reported 2020-08-07 07:15:18 PDT
Refresh WritableStream up to spec
Attachments
Patch (401.27 KB, patch)
2020-08-07 07:25 PDT, youenn fablet
no flags
Patch (401.24 KB, patch)
2020-08-07 07:30 PDT, youenn fablet
no flags
Patch (414.54 KB, patch)
2020-08-09 14:24 PDT, youenn fablet
no flags
Patch (413.46 KB, patch)
2020-08-09 14:31 PDT, youenn fablet
no flags
Patch (413.04 KB, patch)
2020-08-10 01:59 PDT, youenn fablet
no flags
Patch (411.73 KB, patch)
2020-08-10 04:01 PDT, youenn fablet
no flags
Patch for landing (406.62 KB, patch)
2020-08-12 02:47 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2020-08-07 07:25:24 PDT
Radar WebKit Bug Importer
Comment 2 2020-08-07 07:26:07 PDT
youenn fablet
Comment 3 2020-08-07 07:30:06 PDT
youenn fablet
Comment 4 2020-08-09 14:24:36 PDT
youenn fablet
Comment 5 2020-08-09 14:31:06 PDT
youenn fablet
Comment 6 2020-08-10 01:59:31 PDT
youenn fablet
Comment 7 2020-08-10 04:01:36 PDT
Sam Weinig
Comment 8 2020-08-10 10:10:06 PDT
Comment on attachment 406290 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406290&action=review > LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-by-pipe.any-expected.txt:3 > -PASS using pipeTo on Response body should disturb it synchronously > -PASS using pipeThrough on Response body should disturb it synchronously > +FAIL using pipeTo on Response body should disturb it synchronously |this| is not a Promise > +FAIL using pipeThrough on Response body should disturb it synchronously |this| is not a Promise This seems like a regression. Why is ok to start failing this?
youenn fablet
Comment 9 2020-08-10 10:48:59 PDT
(In reply to Sam Weinig from comment #8) > Comment on attachment 406290 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=406290&action=review > > > LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-by-pipe.any-expected.txt:3 > > -PASS using pipeTo on Response body should disturb it synchronously > > -PASS using pipeThrough on Response body should disturb it synchronously > > +FAIL using pipeTo on Response body should disturb it synchronously |this| is not a Promise > > +FAIL using pipeThrough on Response body should disturb it synchronously |this| is not a Promise > > This seems like a regression. Why is ok to start failing this? The current pipeTo/pipeThrough implementation is using an old version of WritableStream API. WritableStream API surface changed and the pipe algorithm changed as well. Note that the current pipeTo/pipeThrough implementation works with any object that mimics the old WritableSteam API. That is why I plan to update the pipeTo algorithm soon, but still keep the current algorithm (that works with any JS object following the old API surface) for a few weeks.
youenn fablet
Comment 10 2020-08-11 06:40:42 PDT
Note also that this patch does not change the current ReadableStream implementation. This patch should have no behavioural effects if WritableStream is disabled, which is the default value.
Sam Weinig
Comment 11 2020-08-11 10:32:03 PDT
(In reply to youenn fablet from comment #9) > (In reply to Sam Weinig from comment #8) > > Comment on attachment 406290 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=406290&action=review > > > > > LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-by-pipe.any-expected.txt:3 > > > -PASS using pipeTo on Response body should disturb it synchronously > > > -PASS using pipeThrough on Response body should disturb it synchronously > > > +FAIL using pipeTo on Response body should disturb it synchronously |this| is not a Promise > > > +FAIL using pipeThrough on Response body should disturb it synchronously |this| is not a Promise > > > > This seems like a regression. Why is ok to start failing this? > > The current pipeTo/pipeThrough implementation is using an old version of > WritableStream API. WritableStream API surface changed and the pipe > algorithm changed as well. > > Note that the current pipeTo/pipeThrough implementation works with any > object that mimics the old WritableSteam API. > That is why I plan to update the pipeTo algorithm soon, but still keep the > current algorithm (that works with any JS object following the old API > surface) for a few weeks. Sorry, I'm not following. Why does this change regress this test?
youenn fablet
Comment 12 2020-08-11 10:38:17 PDT
> Sorry, I'm not following. Why does this change regress this test? This patch is changing WritableStream API surface. ReadableStream.pipeTo implementation is using the WritableStream API so we are breaking this implementation hence the test failures since the tests use WritableStream. ReadableStream.pipeTo needs to be updated according the new algorithm defined by the spec, that will no longer make use of WritableStream public API but lower level private APIs. Once pipeTo implementation is updated, the tests should go back to PASS.
Sam Weinig
Comment 13 2020-08-11 11:18:40 PDT
Is there a way to make this change without breaking the existing functionality?
Geoffrey Garen
Comment 14 2020-08-11 11:20:06 PDT
Comment on attachment 406290 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406290&action=review r=me > Source/WebCore/Modules/streams/WritableStream.js:59 > + // FIXME: underlyingSink, underlyingSink Not sure what this FIXME means > Source/WebCore/Modules/streams/WritableStreamInternals.js:170 > + for (let index = 0, length = requests.length; index < length; ++index) > + requests[index].@reject.@call(@undefined, storedError); Is it intentional that we'll get an exception if writeRequests shrinks during this iteration? > LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt:22 > -PASS ReadableStream (two chunks enqueued, then closed): piping with no options and no destination errors > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and no destination errors > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and no destination errors > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and a destination with that errors synchronously > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination with that errors synchronously > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination that errors on the last chunk > +FAIL ReadableStream (two chunks enqueued, then closed): piping with no options and no destination errors |this| is not a Promise > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and no destination errors |this| is not a Promise > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and no destination errors |this| is not a Promise > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and a destination with that errors synchronously |this| is not a Promise > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination with that errors synchronously |this| is not a Promise > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination that errors on the last chunk |this| is not a Promise What's up with these newly introduced test failures? Not catastrophic, since this is off by default -- but seems like a significant bug. Can we make 'this' a Promise? Same comment for the other test failures.
youenn fablet
Comment 15 2020-08-11 12:59:33 PDT
Thanks for the review. (In reply to Geoffrey Garen from comment #14) > Comment on attachment 406290 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=406290&action=review > > r=me > > > Source/WebCore/Modules/streams/WritableStream.js:59 > > + // FIXME: underlyingSink, underlyingSink > > Not sure what this FIXME means Will comment that we should have probably more WebIDL type checks. > > Source/WebCore/Modules/streams/WritableStreamInternals.js:170 > > + for (let index = 0, length = requests.length; index < length; ++index) > > + requests[index].@reject.@call(@undefined, storedError); > > Is it intentional that we'll get an exception if writeRequests shrinks > during this iteration? This cannot happen, @reject might execute some code but it is guaranteed to be exeuted asynchronously. > > LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt:22 > > -PASS ReadableStream (two chunks enqueued, then closed): piping with no options and no destination errors > > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and no destination errors > > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and no destination errors > > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and a destination with that errors synchronously > > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination with that errors synchronously > > -PASS ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination that errors on the last chunk > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with no options and no destination errors |this| is not a Promise > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and no destination errors |this| is not a Promise > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and no destination errors |this| is not a Promise > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: false } and a destination with that errors synchronously |this| is not a Promise > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination with that errors synchronously |this| is not a Promise > > +FAIL ReadableStream (two chunks enqueued, then closed): piping with { preventClose: true } and a destination that errors on the last chunk |this| is not a Promise > > What's up with these newly introduced test failures? Not catastrophic, since > this is off by default -- but seems like a significant bug. Can we make > 'this' a Promise? Same comment for the other test failures. A follow-up patch will change ReadableStream.pipeTo in case WritableStream flag is defined.
youenn fablet
Comment 16 2020-08-12 02:47:44 PDT
Created attachment 406452 [details] Patch for landing
EWS
Comment 17 2020-08-12 05:25:54 PDT
Committed r265548: <https://trac.webkit.org/changeset/265548> All reviewed patches have been landed. Closing bug and clearing flags on attachment 406452 [details].
Note You need to log in before you can comment on or make changes to this bug.