ring-clojure / ring-clojure/ring

[ring-jetty-adapter] No control over exceptions thrown when obtaining item from ISeq response body

Open
#531 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
3.9k
Forks
528
PR merge metrics
No merged PRs in 30d

Description

Consider the following code returning an ISeq body that throws after some iterations:

(defn now-millis [] (str "data:" (System/currentTimeMillis) "\n\n"))

(def counter (atom 0))

(defn now-throw []
  (swap! counter inc)
  (if (< @counter 5000) "" (throw (ex-info "Test exception" {}))))

(def body (->> (repeat now-millis)
               (interpose now-throw)
               (map (fn [f] (f)))
               lazy-seq))

(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/event-stream"
             "Cache-Control" "no-cache"
             "Connection" "keep-alive"}
   :body body})

When I use Curl (acceptable result):

$ curl localhost:8082

data:1751448129717

data:1751448129717
...
...
curl: (18) transfer closed with outstanding read data remaining

At the server end, I see this exception logged (acceptable result):

[qtp1107779742-52] WARN org.eclipse.jetty.ee9.nested.HttpChannel - /
clojure.lang.ExceptionInfo: Test exception {}
    <stack-trace>

The issue is: I do not have control over how to perform cleanup actions when such an exception is thrown.

Contributor guide

Open the contributing guide

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.

Research direction

Start in the ring-jetty-adapter path that handles an ISeq response body, using the provided handler and curl reproduction to observe the exception. Trace how the Jetty-side failure is surfaced and determine where cleanup control could be exposed. Done means callers can perform cleanup when iteration throws, with behavior covered by a focused reproduction or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.