#394: WebSocketStream

Visit on Github.

Opened Jul 11, 2019

こんにちはTAG!

I'm requesting a TAG review of:

Further details:

We recommend the explainer to be in Markdown. On top of the usual information expected in the explainer, it is strongly recommended to add:

  • Links to major pieces of multi-stakeholder review or discussion of this specification:
  • Links to major unresolved issues or opposition with this specification:

You should also know that...

This proposal is still in the early stages. I plan to implement it in Blink to gather feedback, but we won't necessarily ship it. There will be an origin trial to gauge interest from developers.

We'd prefer the TAG provide feedback as (please select one):

  • open issues in our GitHub repo for each point of feedback
  • open a single issue in our GitHub repo for the entire review
  • leave review feedback as a comment in this issue and @-notify [github usernames]

Please preview the issue and check that the links work before submitting. In particular, if anything links to a URL which requires authentication (e.g. Google document), please make sure anyone with the link can access the document.

¹ For background, see our explanation of how to write a good explainer.

Discussions

Discussed Jul 1, 2019 (See Github)

David: any relationship to Web Transport?

Ken: we reviewed web sockets ... this address some issues TAG identified with existing APIs... everything to be streamable - this tackles that. They are doing some clean-up in the API as well...

(discussion of venue and it being early stage work)

Hadley: feels early for us to engage. Is there related work we should link to?

Ken: also related to web transport... mentioned in the explainer as web transport may supercede this.

Dan: Agree with Hadley, not clear how we should engage given that it's somebody's private repo + google doc with no chosen venue.

Dan: Let's bump two weeks and wait for responses.

Comment by @ricea Jul 11, 2019 (See Github)

See also the review of the existing WebSocket API at #268.

Comment by @martinthomson Jul 15, 2019 (See Github)

@ricea, The underlying protocol supports large messages. How do you anticipate handling very large messages, such as ones that can't be backed by physical memory (or in the extreme, logical memory)? It seems like you don't get back pressure in that case.

Would it be better to provide a stream of streams, or use the fetch mixin for each chunk?

Comment by @ricea Jul 16, 2019 (See Github)

@martinthomson My tentative plan is to use a stream of streams. My concern is that this will be hard to understand and use, which is one reason why I'm not trying to tackle it yet.

Using the fetch mixin for each chunk is a really interesting idea. I think it has potential.

The way I see backpressure working with a stream-of-streams is that you have to read the whole of one message before it will give you another one. I think it's possible to explain and justify this with a stream-of-streams, but with a stream-of-bodies people might strongly object that they should be able to just discard the message without reading it. I'm not sure what to do about that.

Comment by @torgo Jul 17, 2019 (See Github)

Hi @ricea what is the intended venue for this work?

Comment by @dbaron Jul 17, 2019 (See Github)

I'm curious if there is or should be any relationship to the work on Web Transport (#389) -- e.g., if Web Transport is now looking at doing a more stream-based API -- should that be similar to or based on or converge with this?

Comment by @ricea Jul 17, 2019 (See Github)

@torgo What I've been discussing is removing the WebSocket parts from the Fetch Standard and HTML Standard and combining them into a new "WebSocket Standard". Then that would be a natural home for WebSocketStream.

I must admit I haven't given much consideration to a plan B.

Comment by @ricea Jul 17, 2019 (See Github)

I'm curious if there is or should be any relationship to the work on Web Transport (#389) -- e.g., if Web Transport is now looking at doing a more stream-based API -- should that be similar to or based on or converge with this?

I expect they will be similar. WebTransport has a lot more variables which may dictate a different API shape. I hope that experience with WebSocketStream will inform the design of WebTransport.

Comment by @martinthomson Jul 19, 2019 (See Github)

If it were me, any work in this area might want to be chartered alongside (as in the same group) as what does WebTransport. Assuming that both are done, that is. I would want the same API in both cases.

As for stream of streams, we don't want to expose the GC, so we would need to have each body drained. Most of the accessors aren't a problem, but if you get a stream, then that stream would need to be exhausted before the next message can appear.

Comment by @ricea Aug 27, 2019 (See Github)

There are now some tests at https://github.com/web-platform-tests/wpt/tree/master/websockets/stream-tentative. I need to add a lot more.

Comment by @dbaron Sep 12, 2019 (See Github)

@kenchris and I are looking at this in a breakout at the TAG face-to-face meeting in Tokyo.

I'm a little unclear on what code using this stream-of-streams model would look like; if you're going down that route, it would be interesting to see an explainer. It sounds like you might be talking about this for a later version of the API.

That said, we're happy to see this area being worked on -- the stated goals seem worthwhile -- and would again encourage you to make sure this effort fits well with other areas of work like web transport that are happening at the same time.

I feel like to find a bit of time outside of this meeting to look into this in a little bit more detail -- but on the other hand maybe that makes more sense slightly later in the process. Would you like to get more feedback at this stage, or do you think it would be better to wait a bit before taking a closer look at the spec?

Comment by @ricea Sep 12, 2019 (See Github)

I'm a little unclear on what code using this stream-of-streams model would look like; if you're going down that route, it would be interesting to see an explainer. It sounds like you might be talking about this for a later version of the API.

For reading, something like

for await (const message of webSocketStream.readable) {
  for await (const chunk of message) {
    await processChunk(chunk);
  }
  await processEndOfMessage();
}

It would probably be good for me to write up a set of proposals for how streaming within a message should work, but I want to get the first iteration of WebSocketStream standardised first.

Would you like to get more feedback at this stage, or do you think it would be better to wait a bit before taking a closer look at the spec?

At this point I'm waiting for feedback from the origin trial before proceeding with standardisation. While I welcome any input, it would probably be a more efficient use of your time to wait until there is a draft standard.

Discussed Oct 1, 2019 (See Github)

David: looked at issue, not sure whether it's worth more now or waiting (per Adam's comment)

Hadley: How are they doing an origin trial if there's no draft spec?

(some discussion of origin trials and continued changes to specs)

Peter: could close and ask to reopen when they have more

David: or alternatively maybe I should look a little more now... 2 weeks?

Discussed Nov 1, 2019 (See Github)

David: Adam suggested maybe we should look at it later. We might want to do a breakout at the f2f

Comment by @dbaron Dec 3, 2019 (See Github)

Cycling back to this briefly at a breakout with @ylafon, although we probably don't need to dig in a lot right now...

So the current model (not stream-of-streams model) is that WebSocketStream is a stream of messages? Or is it a stream of chunks/frames? Or does the distinction matter given what browsers support today? (From the specs it looks like WebSockets have a concept of messages split across frames, but the explainer seems to imply that that vision isn't really available today.)

Comment by @ylafon Dec 3, 2019 (See Github)

Also the comment made by @dbaron on WebTransport is worth exploring, both specifications seem to have similar goals. Would it be possible to have an explainer about the fundamental differences between the two approaches and what would prevent defining only one API there?

Comment by @dbaron Dec 4, 2019 (See Github)

For what it's worth -- maybe a more general way to frame my previous comment is that perhaps it would be helpful if the explainer assumed a bit less knowledge about the space already. It doesn't need to explain the web from first principles, but having a few more paragraphs to explain the basics of what this is building on would likely be helpful.

Comment by @dbaron Mar 3, 2020 (See Github)

@kenchris and I are looking at this in a breakout at our Wellington face-to-face.

We're curious what the status of this is. There was discussion in the past about changing to a stream-of-streams model? Has that been abandoned, or is that going to move forwards?

It would also be useful to have some explainer updates to explain how this fits with other work and perhaps how it relates to both specification and reality of web sockets (see earlier comment).

It sounds like there is implementation work proceeding and this is available behind a flag, and it sounds like there's been some performance work on that implementation. Is that for the stream-of-messages (or stream-of-chunks) model?

Is it at a stage where TAG feedback would be useful, or would that be more useful at some point in the past or future?

Comment by @ricea Mar 3, 2020 (See Github)

We're curious what the status of this is. There was discussion in the past about changing to a stream-of-streams model? Has that been abandoned, or is that going to move forwards?

We are leaning towards shipping based on developer feedback, but we haven't made a final decision.

It's possible we will support a stream-of-streams model in the future, but I expect to only support stream-of-messages (strings or BufferSources) in the first shipped version.

It would also be useful to have some explainer updates to explain how this fits with other work and perhaps how it relates to both specification and reality of web sockets (see earlier comment).

Sorry, I have been remiss in updating the explainer. I will do it but I can't guarantee when.

It sounds like there is implementation work proceeding and this is available behind a flag, and it sounds like there's been some performance work on that implementation. Is that for the stream-of-messages (or stream-of-chunks) model?

Yes, it is available behind the experimental-web-platform-features flag in Chrome and I have done some performance work in response to early feedback. This is the stream-of-messages model.

Is it at a stage where TAG feedback would be useful, or would that be more useful at some point in the past or future?

Yes. Initial developer response to the API shape is positive, so more feedback would be useful at this point.

Comment by @dbaron Mar 3, 2020 (See Github)

Which of the documents represent the current state of things well, for us to focus on when giving feedback?

Comment by @ricea Mar 5, 2020 (See Github)

Which of the documents represent the current state of things well, for us to focus on when giving feedback?

https://github.com/ricea/websocketstream-explainer/blob/master/README.md is still accurate but I haven't yet updated it it to address the deficiencies noted here. Sorry.

I'm also interested in feedback in the behaviour described in https://github.com/ricea/websocketstream-explainer/issues/6, which I have not yet added to the explainer.

Comment by @tomayac May 31, 2020 (See Github)

FYI, I have written about this API some weeks ago. The article sparked quite some developer interest in the topic.

Discussed Aug 1, 2020 (See Github)

Dan: this came out of the Abyss... Should we close it?

Ken: it's behind a flag in Chrome

Sangwhan: no other browser seems to care about it?

Ken: let's do a ping and ask for an update?

Dan: can we ask what the crossbrowser support story is? Also what's the venue and the intended venue?

Yves: nothing since April on their repo.

Ken: not sure it's a Fugu thing.

Ken: moz standards position ... seems positive...

Sangwhan: but has that position changed?

Ken: people seem to agree it's worth prototyping.

Sangwhan: I was positive... but given that web transport is coming this seems a little interim. And given that other browsers don't seem to be active in implementing this could be transitional.

Ken: Mozilla put this as part of the web transport framework... They closed their standards position issue...

Ken: Oh it was about Web Transport: https://github.com/mozilla/standards-positions/issues/167#issuecomment-684545844

[bump to the 14th?]

Discussed Sep 1, 2020 (See Github)

Ken: no update - from 13 days ago

Dan: for other issues that have "timed out" we've closed them... Maybe give them one more chance?

Ken: I will also ping Alex Russell

Comment by @kenchris Sep 1, 2020 (See Github)

Hi there, any update on this?

What is the cross-browser/vendor support story? Also in what venue is this work taking place?

Comment by @kenchris Sep 14, 2020 (See Github)

Ping @ricea

Comment by @ricea Sep 17, 2020 (See Github)

@kenchris Sorry, there hasn't been much progress yet. Expect more activity in the next month. The expected venue is WHATWG.

We will need cross-browser buy-in for standardisation, so it will be solidified soon. Currently there have only been informal discussions.

Comment by @crowlKats Dec 18, 2020 (See Github)

What is the state on this? It would be great to see a proper spec written for WebSocketStream as there is some interest at Deno to implement it.

Comment by @kenchris Jan 28, 2021 (See Github)

Is it OK if we close this, and you reopen when/if you get cross-browser buy in? @ricea

Comment by @ricea Jan 29, 2021 (See Github)

Is it OK if we close this, and you reopen when/if you get cross-browser buy in? @ricea

Yes, that's fine.

Discussed May 1, 2021 (See Github)

Ken: we should close.

Dan: they're going to come back to us when ...

Ken: when they get cross-browser buy in.

[closed]