ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.73k stars 518 forks source link

ring hangs when attempting to use websockets with :async? true #499

Closed hiredman closed 3 months ago

hiredman commented 3 months ago

reported by Thierry in the clojurians slack.

https://downey.family/p/2024-03-22/jetty-test.clj.html is a little reproducer that monkey patches ring to call complete, if you remove the monkey patching it hangs.

LouDnl commented 3 months ago

I can confirm that implementing this monkey patch makes the async response work immediately!`

weavejester commented 3 months ago

Thanks for the report! I was wondering how this could have gotten past the tests, but it turns out this is an omission in the test suite; websockets are never tested with async handlers!

I'll plug the hole in the test suite and release a fix this weekend. Looks like it should just be a case of changing:

(upgrade-to-websocket request response response-map)

To:

(do (upgrade-to-websocket request response response-map)
    (.complete context))
LouDnl commented 3 months ago

Thanks in advance @weavejester