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

net/http: Server.Shutdown doc example bug: no exit on error #30641

Closed
justinfx opened this issue Mar 6, 2019 · 4 comments
Closed

net/http: Server.Shutdown doc example bug: no exit on error #30641

justinfx opened this issue Mar 6, 2019 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@justinfx
Copy link

justinfx commented Mar 6, 2019

It appears the doc example that is provided for http.Server.Shutdown has a bug.
https://godoc.org/net/http#Server.Shutdown

The example shows that when the listener returns, it only prints the error as opposed to being fatal. This would cause the process to block on the done channel until SIGINT is actually sent.

Reproduction of bug:
https://play.golang.org/p/LCSLoMWIMrR

Should the error handling use log.Fatal?

@agnivade
Copy link
Contributor

agnivade commented Mar 7, 2019

Ok, so you are talking about cases where the listener returns on its own without calling Shutdown or Close, in which case, it won't be an ErrServerClosed.

Let's see what @bradfitz says.

@justinfx
Copy link
Author

justinfx commented Mar 7, 2019

That's correct. My included reproduction shows a case where a bad address was provided so the listener fails immediately. But it won't exit because its waiting on the graceful shutdown channel, which never gets touched.

@julieqiu julieqiu added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 11, 2019
@agnivade
Copy link
Contributor

agnivade commented Apr 8, 2019

@bradfitz thoughts ?

@agnivade
Copy link
Contributor

agnivade commented Jul 5, 2019

Fixed with 04e2e81

@agnivade agnivade closed this as completed Jul 5, 2019
@golang golang locked and limited conversation to collaborators Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants