You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently what happens is that in Pubsub.prototype.unsubscribe, the handler for the topic is first deleted before the mqtt client unsubscribes from the topic. During this time however (when the topic handler no longer exists but the mqtt client has not yet completed unsubscribing), a publisher can publish to the topic which will invoke a non-existent handler.
Error received:
Uncaught TypeError: self.handlers[topic] is not a function
at MqttClient.<anonymous> (C:\Users\Benji\ThingsJS\ThingsJS\lib\core\Pubsub.js:39:23)
Handler should probably be removed after mqtt client successfully unsubscribes first.
The text was updated successfully, but these errors were encountered:
I'd argue that the handler should still be removed before the actual client.unsubscribe call, as the user of the Pubsub object probably intends to unsubscribe immediately. In other words, the user does not wish to listen to the given topic as soon as she calls pubsub.unsubscribe, so if messages are received during this process, it should probably be ignored.
i.e.
User calls pubsub.unsubscribe
Handler is deleted
Our object calls client.unsubscribe
Mqtt message ACKed
So if a message is received after 1, but before 4, they should not be handled.
That said, to handle the error you provided, I think we can put a check and print a warning if there is no handler.
Currently what happens is that in Pubsub.prototype.unsubscribe, the handler for the topic is first deleted before the mqtt client unsubscribes from the topic. During this time however (when the topic handler no longer exists but the mqtt client has not yet completed unsubscribing), a publisher can publish to the topic which will invoke a non-existent handler.
Error received:
Handler should probably be removed after mqtt client successfully unsubscribes first.
The text was updated successfully, but these errors were encountered: