Code Monkey home page Code Monkey logo

poll-until-promise's People

Contributors

adamhamlin avatar alonmiz avatar dependabot[bot] avatar ojamui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

poll-until-promise's Issues

Feature Request: Maximum interval when using `backoffFactor`

Hi,

Would you accept a PR for a new option like maxBackoffInterval? For example, if you specified interval = 1, backoffFactor = 2, and maxBackoffInterval = 10, you'll get retries at 1, 2, 4, 8, 10, 10, 10, 10, 10, ... and so on until success or timeout reached.

Backoff retry is obviously great but growing without bound is probably not wanted in practice.

Thanks!

Using `backoffFactor` will affect the first retry interval

For example, if you use backoffFactor = 2 and interval = 1000, the first retry will take place after 2000ms. I would expect the first retry to take place after 1000ms and the second retry to take place after 2000ms.

If that is intentional, a usage note in the docs would be nice.

Feature: `maxAttempts` and fail-fast when `stopOnFailure===false`

Hi @AlonMiz,

Curious if you'd be interested in a PR for the following:

  • maxAttempts -- Sometimes, the semantics of "attempt this operation X times" are preferable over "attempt this operation until X time has passed". You could get close to this behavior by setting timeout = interval * numDesiredAttempts, but it's not exact/guaranteed and it also gets more complicated if you're using a backoffFactor or similar. Note that this option is additive and wouldn't replace the timeout; if maxAttempts is passed, then polling stops when either the timeout is reached OR attempts are exhausted.

  • fail-fast when stopOnFailure===false -- The stopOnFailure setting is all-or-nothing; that is, either ANY error will stop the loop, or no errors will. It would be nice to have some dedicated error that could be conditioned to stop the loop even when stopOnFailure is false.

// Usage in execution function:
throw new AbortError(myError); // <--- stops polling immediately, myError is reported

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.