knative-extensions / knative-extensions/func-go
Blocking sends to stop channel can deadlock goroutines
- Dominant language
- Go
- Stars
- 7
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
All three middleware packages (http, cloudevents, kafka) use a buffered channel `stop chan error` (buffer size 1) for shutdown signaling. Multiple goroutines send to this channel (HTTP server, consumer/client loop, Start hook, signal handler), but only one value is ever read by the `select` in `Start()`.
If the buffer is already full when another goroutine tries to send, or if `Start()` has already returned and no receiver remains, the sending goroutine blocks forever (leaked goroutine).
**Fix:** Replace blocking sends with non-blocking sends:
```go
select {
case s.stop <- err:
default:
}
```
**Affected files:**
- `http/service.go`
- `cloudevents/service.go`
- `kafka/service.go`
Found during review of #169.
Contributor guide
Research direction
Start with the blocking stop-channel sends in http/service.go, cloudevents/service.go, and kafka/service.go, comparing how each middleware signals shutdown. Replace the blocking sends in all three files with the specified non-blocking behavior, then verify that shutdown signaling no longer leaves goroutines blocked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kafka
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100