taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.74k stars 196 forks source link

`:chsk/state :open?` is true when disconnected on page navigation #380

Closed hoxu closed 1 year ago

hoxu commented 4 years ago

When Firefox navigates to another page and the websocket disconnects, :chks/state is fired, but it erroneously contains :open? true.

From browser console:

09:47:00.232 2020-10-01T06:47:00.230Z DEBUG [taoensso.sente:1230] - Clean WebSocket close, will not attempt reconnect taoensso.timbre.appenders.core.js:158:15
09:47:00.238 !!! :chsk/state  [{:type :ws, :open? true, :ever-opened? true, :csrf-token nil, :uid #uuid "706f5103-4694-4db8-9146-fe53e01901c1", :handshake-data {:app-version dev}, :first-open? true} {:type :ws, :open? true, :ever-opened? true, :csrf-token nil, :uid #uuid "706f5103-4694-4db8-9146-fe53e01901c1", :handshake-data {:app-version dev}, :first-open? false, :last-ws-close {:udt 1601534820230, :ev #object[CloseEvent [object CloseEvent]], :clean? true, :code 1001, :reason }}] cljs.core.js:168:20

new-state-map contains :open? true, even though the connection is closed.

The relevant debug print is called from here:

https://github.com/ptaoussanis/sente/blob/80d9acd64f86ea2288d48a17c94443e1358fd8ab/src/taoensso/sente.cljc#L1226-L1232

Firefox 81.0

ptaoussanis commented 1 year ago

Thanks for the report! Will be addressed in forthcoming v1.18, apologies for the long delay!