-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we feed the [[OutgoingDatagramsQueue]] without prematurely resolving write promises? #400
Comments
At the moment, I'm not too familiar with WebTransport, but maybe you can try passing If that doesn't work, then you'll have to wait for whatwg/streams#1190. With that, you'll be able to set |
Meeting:
|
The streams spec requires the promise from The reason we implement our own outgoing queue for datagrams is that we need to able to remove expired datagrams from the queue. If we used the WritableStream built-in queue then new datagrams could be stuck behind arbitrarily stale datagrams. |
Yes, WebTransport datagrams is an unreliable sink, which is different from a typical WritableStream sink. Adding an option to remove the queue in WritableStream may be acceptable (to whatwg/streams), and that may be useful for other sinks - for example if the sink wants to batch chunks. Even with this, we need to care about the distinction between the return value of for (const datagram of datagrams) {
await writer.ready;
writer.write(datagram).catch(() => {});
} We need more than See also: wpt/webtransport/datagrams.https.any.js |
Yes, though in theory at least, this seems like it could have been done at the point of sending. E.g.
I suspect the reason has more to do with needing a send queue on a different thread/process and feeding it efficiently.
Maybe, or could we get away with relying on the whatwg queue in the meantime and adding a big spec note saying that "oh by the way, this sink's queue is special and should be optimized to be on a different thread/process?"
Yes, I think this is the important point, that the outcome we want seems desirable: the observable behavior of the promises from writer.write() and writer.ready are consistent with WHATWG queues having been used. |
Meeting:
|
Meeting:
|
@yutakahirano wrote in #21 (comment):
This seems like an algorithm bug. [[OutgoingDatagramsQueue]] says: "A queue of tuples of an outgoing datagram, a timestamp and a promise which is resolved when the datagram is sent or discarded."
But that last description gels poorly with what we've written writeDatagrams to actually do: "If the length of datagrams.[[OutgoingDatagramsQueue]] is less than datagrams.[[OutgoingDatagramsHighWaterMark]], then resolve promise with undefined."
I sort of remember this: we were trying to feed the [[OutgoingDatagramsQueue]] by prematurely resolving the write promises. But is this the correct/only way? I worry we've created our own HighwaterMark algorithm, and should instead be using something in the streams spec here, but I don't know what that is or that the correct spec hooks exist. @ricea or @MattiasBuelens do you know?
In theory, there are two promises it seems a sink should be able to control 1) the one from
.ready
and 2) the one from.write
:If we could control 1 here, it might leave 2 to retain its original meaning of "when the datagram is sent or discarded."
The text was updated successfully, but these errors were encountered: