Skip to content

net/http: missing error handling in serveContent #58556

Closed
@agnivade

Description

@agnivade

What version of Go are you using (go version)?

$ go version
go version devel go1.21-a6ddb15f8f Tue Jan 24 17:58:12 2023 +0000 linux/amd64

What did you do?

I ran into this while debugging some failures while trying to stream a file from S3. We noticed problems where suddenly AWS started to return huge numbers of 403, but there were no error logs in our server. We eventually figured out the root cause to be a rate limiting issue, but we had to sift through CloudTrail logs to find that. The expectation was that it would appear in the server logs.

Digging a bit deeper while trying to reproduce locally, I narrowed it down to a missing error handler in:

go/src/net/http/fs.go

Lines 352 to 354 in 518889b

if r.Method != "HEAD" {
io.CopyN(w, sendContent, sendSize)
}

The problem is that if the stream breaks mid-way there is no indication anywhere as to what happened. The server will keep chugging along perfectly fine.

I have a 2 line CL already prepared for this which logs the error. But just wanted to create an issue for discussion in case this was intented in any ways.

I am happy to create a standalone reproducer for further proof, but I think it is pretty self-evident.

/cc @neild

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions