mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 10:56:10 +02:00
🐛 Fix NPE on notifications module (on abrupt disconnect).
This commit is contained in:
parent
76b7272a72
commit
0f7372bfb4
1 changed files with 11 additions and 2 deletions
|
@ -99,6 +99,15 @@
|
||||||
;; (mtx/counter {:id "notificatons__messages_counter"
|
;; (mtx/counter {:id "notificatons__messages_counter"
|
||||||
;; :help "A total number of messages handled by the notifications service."}))
|
;; :help "A total number of messages handled by the notifications service."}))
|
||||||
|
|
||||||
|
(defn- ws-send
|
||||||
|
[conn data]
|
||||||
|
(try
|
||||||
|
(when (jetty/connected? conn)
|
||||||
|
(jetty/send! conn data)
|
||||||
|
true)
|
||||||
|
(catch java.lang.NullPointerException e
|
||||||
|
false)))
|
||||||
|
|
||||||
(defn websocket
|
(defn websocket
|
||||||
[{:keys [file-id team-id redis] :as cfg}]
|
[{:keys [file-id team-id redis] :as cfg}]
|
||||||
(let [in (a/chan 32)
|
(let [in (a/chan 32)
|
||||||
|
@ -114,8 +123,8 @@
|
||||||
(a/go-loop []
|
(a/go-loop []
|
||||||
(let [val (a/<! out)]
|
(let [val (a/<! out)]
|
||||||
(when-not (nil? val)
|
(when-not (nil? val)
|
||||||
(jetty/send! conn (t/encode-str val))
|
(when (ws-send conn (t/encode-str val))
|
||||||
(recur))))
|
(recur)))))
|
||||||
|
|
||||||
(a/go
|
(a/go
|
||||||
(a/<! (on-connect ws))
|
(a/<! (on-connect ws))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue