Previously, the subscribe method of the QueriesClient class had incorrect handling of close and unsubscribe events. The event received from stream.on("close") did not lead to any consequences. If the connection to KubeMQ was lost, then reconnection could not occur, because isClosed was always false.
I also moved the subscription from cycle-dependent to event mode, so as not to once again load the event loop with unnecessary functions deferred every second.
This PR fixes #1.
Previously, the
subscribe
method of theQueriesClient
class had incorrect handling of close and unsubscribe events. The event received fromstream.on("close")
did not lead to any consequences. If the connection to KubeMQ was lost, then reconnection could not occur, becauseisClosed
was alwaysfalse
.I also moved the subscription from cycle-dependent to event mode, so as not to once again load the event loop with unnecessary functions deferred every second.
Here is a bug,
onClose
was not called on the other side: https://github.com/kubemq-io/kubemq-js/blob/main/src/queries.ts#L296C1-L304C12