oliyh / re-graph

A graphql client for clojurescript and clojure
460 stars 39 forks source link

Reconnect/destroy not working for clj websocket subscriptions #93

Closed vincentjames501 closed 11 months ago

vincentjames501 commented 1 year ago

When I call (re-graph/destroy {}) after making a subscription on a websocket or if the websocket is closed due to external factors I get the following:

2022-07-27T16:33:54.173-0700 VPizzo-MBP-932.singlewire.lan ERROR [re-frame.loggers:1] - re-frame: while handling [:re-graph.internals/on-ws-close {:instance-id :re-graph.internals/default}] , dispatch-sync was called for [:re-graph.internals/reconnect-ws {:instance-id :re-graph.internals/default}] . You can't call dispatch-sync within an event handler.

In the case where the connection closed on the server it does not attempt to reconnect and resume the subscription.

rhishikeshj commented 11 months ago

I am also facing the same issue. Also seems to prevent my integration tests (which integrant/halt the system when done) from finishing

oliyh commented 11 months ago

Thanks for the report, I will try to find time to look.

What version of re-frame are you using, by the way?

rhishikeshj commented 11 months ago

In my project I am not specifying the re-frame version so I guess its whatever is used by re-graph by default. for 0.2.0 re-graph that seems to be 1.2.0 I am using re-graph 0.2.0

oliyh commented 11 months ago

@rhishikeshj are you experiencing this while using run-test-sync? Or does it also happen in other places?

rhishikeshj commented 11 months ago

@oliyh no. this is a JVM test using a simple deftest and the re-graph/destroy comes from an ig/halt which is called from the :once fixture of the test once the test is completed

oliyh commented 11 months ago

Pushed 0.2.1-SNAPSHOT to clojars with an improvement to destroy, but as discussed it doesn't solve the problem, which I believe exists in the jvm implementation of re-frame.