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

Comments

Projects
None yet
3 participants
@justinfx
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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.

@agnivade

This comment has been minimized.

Copy link
Member

commented Apr 8, 2019

@bradfitz thoughts ?

@agnivade

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

Fixed with 04e2e81

@agnivade agnivade closed this Jul 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.