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

fix: set session as gracefully closing on goaway frame #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions source/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ class Agent extends EventEmitter {
session.destroy();
});

session.once('goaway', () => {
// Prevent session from being used for new requests.
// The session will eventually emit either an 'error' or 'close' event.

// See https://datatracker.ietf.org/doc/html/rfc7540#section-6.8
// There is an inherent race condition between an endpoint starting new streams and the remote sending a GOAWAY frame.
// Receivers of a GOAWAY frame MUST NOT open additional streams on the connection, although a new connection can be established for new streams.

gracefullyClose(session);
});

session.once('close', () => {
this._sessionCount--;

Expand Down