Skip to content

proposal: net/http: access to HTTP/2 GoAwayError #74578

Open
@drigz

Description

@drigz

Proposal Details

In #53896, h2_error.go was added, allowing people to write:

var perr http2.StreamError
if errors.As(err, &perr) {
	// ... handle stream error ...
}

instead of:

if strings.Contains(err.Error(), "stream error: ")

and hoping no one ever changes the string or adds that string to another error.

I've encountered GOAWAY errors from a gRPC server and would like to set a retry policy for these, but errors.As() can't be used. I don't want to retry all url.Errors that I receive from the gRPC server as I don't want to over-retry and trigger an outage, so for now I'm limited to substring search.

What do you think about extending the approach used here to work for http2GoAwayError as well? https://go.dev/src/net/http/h2_error.go

The only other struct this might apply to is (http2)ConnectionError, but I don't have personal experience with that so I'm not sure if it's needed.

Previous requests (pre Go 1.13 errors):

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions