hedera-hcs-chat-js
hedera-hcs-chat-js copied to clipboard
Replace default await periods with a try/catch
Currently, we're waiting ~9 seconds for our new topic to be persisted to a mirror node, allowing us to successfully create a subscription to that topic. We should replace this with a try/catch block on an interval (2-3 seconds could make sense?), with a maximum # of retries.
Hey @Cooper-Kunz -- looks like this is not an issue with socketio anymore with the version that's running 2.4.0
. I removed the 9 second await and socketio handles the reconnection; you can modify the default socketio reconnection logic but imo this works fine when just removing the 9 second await.
init() using default .env config
init() creating new topic
TopicCreateTransaction() submitted tx
TopicCreateTransaction() success! new topic 0.0.48965465
ConsensusTopicCreateTransaction() waiting for new HCS Topic & mirror node (it may take a few seconds)
not awaiting here
MirrorConsensusTopicQuery() 0.0.48965465
Error subscribing to topic 0.0.48965465 during attempt 0. Waiting 250 ms before next attempt: Topic 0.0.48965465 does not exist
Error subscribing to topic 0.0.48965465 during attempt 1. Waiting 500 ms before next attempt: Topic 0.0.48965465 does not exist
Error subscribing to topic 0.0.48965465 during attempt 2. Waiting 1000 ms before next attempt: Topic 0.0.48965465 does not exist
Error subscribing to topic 0.0.48965465 during attempt 3. Waiting 2000 ms before next attempt: Topic 0.0.48965465 does not exist
TopicMessageSubmitTransaction() {"operatorAccount":"0.0.48965332","client":"0sxy2gR6ixm_IQpJAAAA","message":"test"}
Response from TopicMessageQuery() [object Object]
Parsed mirror message default