Giter Site home page Giter Site logo

Comments (4)

molnarg avatar molnarg commented on August 28, 2024

Hm, what we lose with this is the guarantee that frames are sent (and received) in the order they are written in the stream. I looked this up in the spec and it says:

The order in which frames are sent on a stream is significant. Recipients process frames in the order they are received. In particular, the order of HEADERS, and DATA frames is semantically significant.

So I don't think we can optimize this.

from node-http2-protocol.

nwgh avatar nwgh commented on August 28, 2024

I'm not so sure about that. It may not be as simple as I was originally thinking, but I think it's doable. When I was looking at this, I wasn't thinking about HEADERS or DATA particularly, this came up when I was implementing ALTSVC. Here are some things that we would need to guard against:

  • Sending any DATA before we've sent the full header block (HEADERS|PUSH_PROMISE CONTINUATION*) (because duh)
  • Reordering frames within a header block or a sequence of DATA frames (because duh)
  • Sending a SETTINGS that updates the compression context out-of-order with a header block (since the header block would depend on the previous max header table size)
  • Sending a RST_STREAM if we have any data waiting (since it's possible that the other endpoint may want to do something with the data that we've sent, such as saving a partial download for a later range request)

The only other one that could get a little weird is sending a PRIORITY, though if we're sending DATA on an particular stream, we're probably not the one that should be sending PRIORITY frames for that stream, anyway. (Obviously we wouldn't want to send PRIORITY before HEADERS.)

I don't see any issues sending, for example, ALTSVC on a stream that's blocked on flow control. I can even see a reason to actually do so - if you believe the client isn't going to be opening its window any time soon but that it's not malicious (not an incredibly likely scenario, but still...), you may want to try to redirect it to get a new connection with a new flow control window.

from node-http2-protocol.

molnarg avatar molnarg commented on August 28, 2024

Yeah, it's doable in certain scenarios. I'm OK with handling the cases we know are safe specially, but I'm afraid of using very complicated logic to do this. How about implementing a _pushUpstreamWithoutFlowControl() method on the Stream class as an alternative to _pushUpstream() which could be used in cases when we know this can not cause trouble (like ALTSVC)?

It would look like this:

Stream.prototype._pushUpstreamWithoutFlowControl = function _pushUpstreamWithoutFlowControl(frame) {
  this.upstream._parentPush(frame); // Logs the frame and pushed directly into the output queue
  this._transition(true, frame);
};

from node-http2-protocol.

nwgh avatar nwgh commented on August 28, 2024

Yeah, I think that seems like a reasonable way to go about it. Once draft14 lands (which should be as soon as Martin has the spec revision ready, unless he surprises me with some last-minute changes), I'll work on adding this.

from node-http2-protocol.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.