clj-commons / clj-commons/aleph
Default rejected-handler will leak buffers in raw stream HTTP servers
- Dominant language
- Clojure
- Stars
- 2.6k
- Forks
- 242
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 1
Description
# Problem
Given an HTTP server started with `:raw-stream? true`, when `aleph.http.server/handle-request` hits the `RejectedExecutionException` path, the default handler (i.e. when no custom `rejected-handler` was provided) will leak any byte buffers which are already present in the request's `:body` stream.
# Possible solutions
1. Drain the body channel and release all byte buffers still contained in it (does that cover all bases?)
2. Document this fact (as suggested by @arnaudgeiser [here](https://github.com/clj-commons/aleph/issues/615#issuecomment-1207209343))
3. Require passing a custom `rejected-handler` when `:raw-stream? true` is passed
Contributor guide
Research direction
Start at aleph.http.server/handle-request and trace the RejectedExecutionException path for servers using :raw-stream? true. Reproduce the default rejected-handler case, inspect ownership of byte buffers already in the :body stream, and establish which proposed behavior prevents leaks; done means the rejected request releases retained buffers without requiring an undocumented custom handler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100