-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
write-body-to-stream
does not behave like in ring.adapter.jetty
#122
Comments
This isn't intentional behavior in Ring; the I'm unsure why this doesn't work in synchronous mode in Ring. My guess is that Jetty is trying to be helpful by closing the stream after the handler completes when in synchronous mode, perhaps using some timeout. Can you raise an issue on the Ring repository so we can investigate this? |
@weavejester thank you for your input! Yes, I'll open an issue in the Ring repository shortly. |
Note sure if it's related to issue we investigated in #113. I will find time this weekend to see |
I investigated this, and at least in the case of Ring, I believe I now understand why this occurs and why it probably isn't a bug: ring-clojure/ring#491 (comment) |
After some investigation I found it has something to do with https://github.com/sunng87/ring-jetty9-adapter/blob/master/src/ring/adapter/jetty9/handlers/sync.clj#L36 When I remove this line, it prints I'm not 100% if async thread is allowed as in this scenario. At least we will need a callback mechanism that once we close the output stream we need to notify Jetty that the request has been successfully handled. |
Hello, first of all, thank you for this library! I am considering using it
instead of the original adapter for a web project, but I ran into an issue with
an SSE handler. Here is a barebone handler that demonstrates the issue:
(Tested with Clojure 1.12.0-alpha5 and Java 21)
With
ring/ring-jetty-adapter {:mvn/version "1.11.0"}
, the endpoint behaves asexpected, streaming each line as soon as they are "produced":
But with
info.sunng/ring-jetty9-adapter {:mvn/version "0.31.0"}
, curl returnsimmediately without displaying any of our "data: x" messages:
I found out an issue explaining that it is perfectly valid for a ring
handler to return while the output-stream remains open, and it may be closed
later in another thread.
Note that this streaming handler only works in the original adapter with the
:async? true
setting. Reading the spec, it is not evident to me why this isthe case, and it's a bit unfortunate as we have to wrap our otherwise completely
synchronous ring application with:
Maybe @weavejester could clarify why this is the case?
The text was updated successfully, but these errors were encountered: