Skip to content
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

[v12.x] Backport http2: fix graceful session close #33059

Closed
wants to merge 2 commits into from

Commits on Apr 25, 2020

  1. http2: wait for session to finish writing before destroy

    PR-URL: nodejs#30854
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    lundibundi authored and targos committed Apr 25, 2020
    Configuration menu
    Copy the full SHA
    759829c View commit details
    Browse the repository at this point in the history
  2. http2: wait for session socket writable end on close/destroy

    This slightly alters the behaviour of session close by first using
    .end() on a session socket to finish writing the data and only then
    calls .destroy() to make sure the Readable side is closed. This allows
    the socket to finish transmitting data, receive proper FIN packet and
    avoid ECONNRESET errors upon graceful close.
    
    onStreamClose now directly calls stream.destroy() instead of
    kMaybeDestroy because the latter will first check that the stream has
    writableFinished set. And that may not be true as we have just
    (synchronously) called .end() on the stream if it was not closed and
    that doesn't give it enough time to finish. Furthermore there is no
    point in waiting for 'finish' as the other party have already closed the
    stream and we won't be able to write anyway.
    
    This also changes a few tests to correctly handle graceful session
    close. This includes:
    * not reading request data (on client side)
    * not reading push stream data (on client side)
    * relying on socket.destroy() (on client) to finish server session
      due to the destroy of the socket without closing the server session.
      As the goaway itself is *not* a session close.
    
    Added few 'close' event mustCall checks.
    
    PR-URL: nodejs#30854
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    lundibundi authored and targos committed Apr 25, 2020
    Configuration menu
    Copy the full SHA
    c9b2081 View commit details
    Browse the repository at this point in the history