Summary
The POST /-/reload handler in weboperations/weboperations.go has two potential hang/safety issues:
- Unbuffered reply channel can cause a deadlock: If the client disconnects after the reload has been queued, the reloader goroutine will block forever trying to send the result back on the unbuffered
errc channel, because no one is receiving.
defer close(errc) is incorrect: The handler is not the sender on this channel — closing it from the handler side is unsafe and could panic the reloader if it tries to send on a closed channel.
- Neither the enqueue nor the reply is context-aware: If the reload queue (
reloadCh) is full or the reload takes too long, the HTTP handler hangs with no way for a client disconnect to unblock it.
Suggested Fix
- Change
errc to a buffered channel of size 1: errc := make(chan error, 1)
- Remove
defer close(errc)
- Wrap both the send to
reloadCh and the receive from errc in select statements that also listen on req.Context().Done()
References
Summary
The
POST /-/reloadhandler inweboperations/weboperations.gohas two potential hang/safety issues:errcchannel, because no one is receiving.defer close(errc)is incorrect: The handler is not the sender on this channel — closing it from the handler side is unsafe and could panic the reloader if it tries to send on a closed channel.reloadCh) is full or the reload takes too long, the HTTP handler hangs with no way for a client disconnect to unblock it.Suggested Fix
errcto a buffered channel of size 1:errc := make(chan error, 1)defer close(errc)reloadChand the receive fromerrcinselectstatements that also listen onreq.Context().Done()References