Skip to content

Handle GOAWAY Frame #89

@mkaufmaner

Description

@mkaufmaner

Currently the http2-wrapper agent instantiates a new ClientHttp2Session with http2.connect in the Agent class. After this session is created a listener is attached for the error event here and the close event here.

However, there is no listener for the goaway event. Since there is no handler to remove sessions which they will continue to be used by subsequent requests. This will then lead to the New streams cannot be created after receiving a GOAWAY error being thrown because the session that received the GOAWAY has not been not removed from the map of available sessions.

See https://github.com/nodejs/node/blob/v16.x/lib/internal/http2/core.js#L1166

// Receiving a GOAWAY frame will cause the Http2Session to first emit a 'goaway'
// event notifying the user that a shutdown is in progress. If the goaway
// error code equals 0 (NGHTTP2_NO_ERROR), session.close() will be called,
// causing the Http2Session to send its own GOAWAY frame and switch itself
// into a graceful closing state. In this state, new inbound or outbound
// Http2Streams will be rejected. Existing *pending* streams (those created
// but without an assigned stream ID or handle) will be destroyed with a
// cancel error. Existing open streams will be permitted to complete on their
// own. Once all existing streams close, session.destroy() will be called
// automatically.

Related to sindresorhus/got#2156

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions