0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00

Improve error handling on websocket code

This commit is contained in:
Andrey Antukh 2024-02-09 10:57:12 +01:00 committed by Andrés Moya
parent ec2eb3d406
commit 43b8ccb52e

View file

@ -15,6 +15,7 @@
[app.util.time :as dt]
[promesa.exec :as px]
[promesa.exec.csp :as sp]
[promesa.util :as pu]
[ring.request :as rreq]
[ring.websocket :as rws]
[yetti.websocket :as yws])
@ -185,17 +186,18 @@
(rws/send channel message)
(recur i))))))
(catch java.nio.channels.ClosedChannelException _)
(catch java.net.SocketException _)
(catch java.io.IOException _)
(catch InterruptedException _cause
(l/dbg :hint "websocket thread interrumpted" :conn-id id))
(catch Throwable cause
(l/err :hint "unhandled exception on websocket thread"
:conn-id id
:cause cause))
(let [cause (pu/unwrap-exception cause)]
(if (or (instance? java.nio.channels.ClosedChannelException cause)
(instance? java.net.SocketException cause)
(instance? java.io.IOException cause))
nil
(l/err :hint "unhandled exception on websocket thread"
:conn-id id
:cause cause))))
(finally
(try
(handler wsp {:type :close})