aleph

regibyte 2025-11-13T22:48:57.742939Z

Hello everyone! Nice to meet you all!! I am testing aleph in a simple app that I’m building for learning purposes, and I have a question regarding resource cleanup, I am using integrant to manage stateful components in my app. The question is: Is there a recommended way to teardown Aleph and close open connections to WS and SSE endpoints? I’ve found an old issue here about graceful shutdowns but didn’t quite understood what the final outcome was https://github.com/clj-commons/aleph/issues/365 The case I have in my application right now is that the connection works, sending SSE events works, connecting to websocket also works fine, everything appears to work as expected, but then I caught some issues in my tests and noticed it happening in my frontend playground too, I’ve tried manually closing all the readers in my tests to ensure that there is no one waiting to flush, that didn’t solve it it appears that the connections established to the aleph server are not closed when the server itself is closed through integrant ig/halt! method (just calls aleph .close method), Then, after 15 seconds the aleph timeout kicks in and somehow kills the open connections, as observed in the logs below

; 2025-11-13T22:43:21.389408Z INFO LOG Filipes-MacBook-Pro.local nexus.db[53,3] initializing db
; 2025-11-13T22:43:21.389999Z INFO LOG Filipes-MacBook-Pro.local nexus.db[68,3] initializing migrations
; 2025-11-13T22:43:21.391022Z INFO LOG Filipes-MacBook-Pro.local nexus.server[332,3] initializing server handler
; 2025-11-13T22:43:21.391815Z INFO LOG Filipes-MacBook-Pro.local nexus.server[352,3] initializing server
;    data: {:options {:port 3456}}
:initiated
clj꞉nexus.user꞉> 
; 2025-11-13T22:43:22.887449Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[23,3] SSE connection established
; 2025-11-13T22:43:22.890874Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[57,3] SSE multi-event connection established
; stream closed? false
; stream closed? false
; 2025-11-13T22:43:27.155235Z INFO SLF4J Filipes-MacBook-Pro.local com.zaxxer.hikari.HikariDataSource HikariPool-5 - Starting...
;    data: {:slf4j/args ["HikariPool-5"]}
; 2025-11-13T22:43:27.209727Z INFO SLF4J Filipes-MacBook-Pro.local com.zaxxer.hikari.pool.HikariPool HikariPool-5 - Added connection org.postgresql.jdbc.PgConnection@569d4ba4
;    data: {:slf4j/args ["HikariPool-5" #object[org.postgresql.jdbc.PgConnection 0x569d4ba4 "org.postgresql.jdbc.PgConnection@569d4ba4"]]}
; 2025-11-13T22:43:27.210189Z INFO SLF4J Filipes-MacBook-Pro.local com.zaxxer.hikari.HikariDataSource HikariPool-5 - Start completed.
;    data: {:slf4j/args ["HikariPool-5"]}
; 2025-11-13T22:43:27.828993Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[44,20] SSE connection closed
; 2025-11-13T22:43:27.829355Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[89,20] SSE multi-event connection closed
; 2025-11-13T22:43:28.005653Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[23,3] SSE connection established
; 2025-11-13T22:43:28.005990Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[57,3] SSE multi-event connection established
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; 2025-11-13T22:43:38.656121Z INFO LOG Filipes-MacBook-Pro.local nexus.server[369,3] stopping server
; Building system db connection
; 2025-11-13T22:43:38.656942Z INFO LOG Filipes-MacBook-Pro.local nexus.db[62,3] tearing down db
; 2025-11-13T22:43:38.657478Z INFO SLF4J Filipes-MacBook-Pro.local com.zaxxer.hikari.HikariDataSource HikariPool-5 - Shutdown initiated...
;    data: #:slf4j{:args ["HikariPool-5"]}
; 2025-11-13T22:43:38.659508Z INFO SLF4J Filipes-MacBook-Pro.local com.zaxxer.hikari.HikariDataSource HikariPool-5 - Shutdown completed.
;    data: #:slf4j{:args ["HikariPool-5"]}
:halted
clj꞉nexus.user꞉> 
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; stream closed? false
; 2025-11-13T22:43:53.659392Z ERROR SLF4J Filipes-MacBook-Pro.local aleph.netty Timeout while waiting for requests to close (exceeded: 15s)
; 2025-11-13T22:43:53.660975Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[44,20] SSE connection closed
; 2025-11-13T22:43:53.661023Z INFO LOG Filipes-MacBook-Pro.local nexus.router.realtime[89,20] SSE multi-event connection closed
PR with sample code https://github.com/RegiByte/clojure-nexus/pull/2

✅ 1
regibyte 2025-11-13T22:55:50.177519Z

I ask this with the intention of understanding if there is any standard practice that I am missing, I don’t think this is related to any aspect of my particular implementation, as I’ve basically followed docs and tutorials and did the simplest thing I could think of Both aleph and manifold are quite new to me, so hopefully this question makes sense to someone more experienced than me

regibyte 2025-11-14T13:46:48.991829Z

After researching more within the aleph and manifold issues I’ve learned that this is actually the default behavior for aleph/netty, the fact that connections remain open during 15 seconds and get closed after this period represents the “graceful shutdown” mechanism acting So I did two things 1. after calling (.close server) I also added an additional call to (netty/wait-for-close server), based on this issue here https://github.com/clj-commons/aleph/issues/638, this forces the ig/halt! call to block while the server is “gracefully shutting down” 2. modified the :shutdown-timeout during dev and tests to be 0, effectively interrupting all requests immediately and shutting down the server

dergutemoritz 2025-11-21T11:07:33.399209Z

@reginaldo.junior696 Sorry for not responding earlier! But you found the correct answer yourself in the meantime 🙂👍

❤️ 1
regibyte 2025-11-21T12:28:34.773829Z

Thank you for confirming my assumption was right @dergutemoritz!! Question: who manages documentation in aleph/manifold? These libraries are simply amazing, but the lack of info in the official docs makes it a bit more difficult to start when compared to say - ring jetty adapter which is documented throughout I would be willing to spend some time gathering documentation and known gotchas to help improve the docs, if that’s acceptable

dergutemoritz 2025-11-21T14:57:21.320239Z

I am currently the only maintainer of both projects. Documentation patches are definitely welcome!

❤️ 1
dergutemoritz 2025-11-21T14:58:48.742789Z

docstrings are in reasonably good shape overall I'd say tho

dergutemoritz 2025-11-21T14:59:19.712329Z

https://github.com/clj-commons/manifold/tree/master/doc

regibyte 2025-11-21T15:04:22.436229Z

Yeah! I have both repos cloned locally, I can use the docstrings as a starting point to understand the internals, look at the github issues and see where people usually get confused, and then write some draft docs in a PR! I would love to help move this needle forward and learn more about both libs along the way ❤️

dergutemoritz 2025-11-21T15:28:56.688569Z

That's great, thanks a lot!

dergutemoritz 2025-11-21T15:29:06.885179Z

Happy to answer any questions and review your work 🙏

dergutemoritz 2025-11-21T15:29:45.938249Z

Having more people familiar with the internals would be great in general

dergutemoritz 2025-11-21T15:30:06.780579Z

also for code reviewing purposes

neumann 2025-11-21T00:56:15.391899Z

Good to know. Thanks for sharing what you found!

1