-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: improve FileServer error logging #33882
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
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
This PR (HEAD: f66c1bb) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/191971 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Brad Fitzpatrick: Patch Set 1: Code-Review-1 This would need a cleaned up commit message (read the instructions in them) and a test, but this change would require a lot more work. This intentionally doesn't log because the majority of the failures logged would be because users closed their tab and broke their TCP connection. That's not worth logging about. Failure to read from the source side is more interesting, though. Let me know if you're still interested in working on it. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 1:
Thanks for the feedback. I'm still happy to work on this. Could you give me further feedback what kind of solution would you like to see? do you think we could set a debug mode from env var like a GODEBUG flag to turn on this error logging? Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Brad Fitzpatrick: Patch Set 1:
No, no new environment variables. Use the https://golang.org/pkg/net/http/#Server.ErrorLog (see the logf func) for logging, but only log if it's not a broken network connection as the reason. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 1:
OK, then replacing the nil check with a type check, like this Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Brad Fitzpatrick: Patch Set 1:
io.Copy (or io.CopyN) don't distinguish between whether the error was from the read size or the write side. So that is likely not enough. I'd also pull it out into a function (or two) to make it more readable & testable. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 1:
Right, as FileSystem/File is an interface we cannot be sure where the net.Error comes from. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 1:
Sorry, i meant wrapping the Reader Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
This PR (HEAD: 7976f48) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/191971 to see it. Tip: You can toggle comments from me using the |
53bd915
to
6139019
Compare
Message from Brad Fitzpatrick: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
This PR (HEAD: 2ae816e) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/191971 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 3e18e1a) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/191971 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 4: TryBot-Result-1 3 of 19 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Gobot Gobot: Patch Set 5: TryBots beginning. Status page: https://farmer.golang.org/try?commit=815b0392 Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Gobot Gobot: Patch Set 5: Build is still in progress... Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Brad Fitzpatrick: Patch Set 5: -Code-Review (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Gobot Gobot: Patch Set 5: TryBot-Result-1 3 of 19 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 5: (1 comment)
Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Errors returned during copying the file content in ServeContent, ServeFile and FileServer were ignored to avoid excessive, meaningless logging. This commit introduces error filtering and logging to ensure that the errors occurring during reading the content are logged. Updates golang#27128
This PR (HEAD: df595d2) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/191971 to see it. Tip: You can toggle comments from me using the |
Message from Béla Hullár: Patch Set 6: sorry, i pushed early, wrapping the writer makes the same test fail Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Béla Hullár: Patch Set 6: Unfortunately it seems that this send file optimization relies on the concrete types on multiple levels. The writer needs to implement ReadFrom (to make Copy use ReadFrom of type response), response.ReadFrom checks for regular file checking the type of the reader (here i can add the errorSaverReader to check the wrapped reader), but then the underlying TCPCon from package net also checks whether the Reader is a file or a LimitedReader, otherwise it skips the send file invocation Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
4a7ed1f
to
0f992b9
Compare
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 4: TryBots beginning. Status page: https://farmer.golang.org/try?commit=cf7a008c Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 4: Build is still in progress... Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 4: TryBot-Result-1 3 of 19 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 5: TryBots beginning. Status page: https://farmer.golang.org/try?commit=815b0392 Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 5: Build is still in progress... Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
Message from Go Bot: Patch Set 5: TryBot-Result-1 3 of 19 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/191971. |
The errors returned during copying the file content in ServeContent,
ServeFile and FileServer were ignored to avoid excessive, meaningless
logging. This commit introduces error filtering and logging to ensure
that the errors occurring during reading the content are logged.
Updates #27128