Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Give taken-over connections a shutdown grace

Open
#95 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
34/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start in gonsole/serve.go: serveOn accepts connections and drain waits during shutdown, and countedListener in gonsole/idle.go shows how connections are already counted until close. Read how ServeListening and Serve return on cancel in gonsole/program.go. Done means a test with a handler that takes a connection over and keeps it open makes drain wait up to Grace and CancelGrace, then close it, instead of returning at once.

Written by the indexing model from the issue text.

Description

enhancement help wanted

Downstream applications that hold WebSockets need them to end cleanly when the server stops.

Current state: a handler can take a connection over from net/http, as a WebSocket does (Go calls this hijacking). Shutdown "does not attempt to close nor wait for hijacked connections" (net/http/server.go:3264-3268). With an idle exit, gonsole counts such a connection until it closes, but drain, the wait at shutdown (gonsole/serve.go:141-169), does not wait for it. A test on gonsole 0.8.0 took a connection over and let its handler return. On a cancel, as on SIGTERM (gonsole/program.go:97), ServeListening and Serve returned nil within a millisecond, though Grace was 2 seconds. The connection still echoed after the return. Shutdown starts the srv.RegisterOnShutdown functions without waiting (net/http/server.go:3281). A goodbye that took 300 ms came after the return, and a real process may have exited by then.

Proposal: in serveOn (gonsole/serve.go:92-116), which both call, keep every accepted connection in a set until its first close, as countedListener counts them (gonsole/idle.go:107-115). drain then waits for the set to empty within Grace and CancelGrace, then closes what is still open, as Traefik does. Test it with a handler that keeps a taken-over connection open.

Trigger: a downstream application needs WebSockets to close cleanly on a restart.

Dominant language
Go
Stars
69
Forks
3
Avg merge
9h 11m
Merged PRs (30d)
38

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gopherium/framework

All issues in gopherium/framework

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.