waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

feat: lightPush auto retry #2032

Closed weboko closed 1 week ago

weboko commented 1 month ago
This is a **feature request** ## Problem It can happen that `lightPush.send` fail due to not having enough quality peers or peers in general. ## Proposed Solutions Enable following API: ```ts node.lightPush.send(encoder, message, { autoRetry: true }); // retries right after peers are available with default timeout of 500ms node.lightPush.send(encoder, message, { autoRetry: { timeout: 1000 } ); // changes timeout to 1s ``` Default values: - `autoRetry` - `false`; - if `autoRetry` is `true` -> `{ timeout: 500, retries: 3 }`; - in other cases should be merged with provided values; This feature should be **disabled by default** as in the worst case scenario it can take some time potentially blocking consumer's app without clear reason. `timeout` is to cap execution by `await` time `retries` is to cap execution by amount of tries to `.send` message to peers ## Notes Original thread - https://github.com/waku-org/js-waku/pull/2003#discussion_r1624717148
danisharora099 commented 2 weeks ago

Did some optimisations on the original PR and autoRetry was necessitated as part of the functionality:

https://github.com/waku-org/js-waku/pull/2003/commits/f97c6a93cb2b2ffb67910f661a94c5c9cfb47fc8 should resolve this

weboko commented 1 week ago

Looks good. Is it merged already, @danisharora099 ?

danisharora099 commented 1 week ago

Looks good. Is it merged already, @danisharora099 ?

Yes! This issue can be closed.

Closing now. Feel free to reopen if you think something is left unaddressed