GithubHelp home page GithubHelp logo

Comments (11)

niftylettuce avatar niftylettuce commented on June 11, 2024 2

Just FYI I already implemented timeout and retry locally. Just need to push it up. I definitely need some help with tests.

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024 2

I pushed my work in progress by the way at 38d2252 if anyone wants to help out with it.

I would love help writing tests for it. Timeouts/retries all need tested.

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024 1

Yeah @antgel, you would be able to refresh JWT token in retryFn.

@akmjenkins I'll gladly award you the bounty if you can open a PR for this https://github.com/niftylettuce/bug-bounties/issues/5

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024

Also, per #92 we should allow a custom callback function to be called on retries, which would allow JWT refresh tokens to be updated for example.

from frisbee.

akmjenkins avatar akmjenkins commented on June 11, 2024

My fetch-retry approach was to leave it entirely up to the user (no opinions based on server response codes). It could be passed into a base frisbee instance or individual requests. The API was pretty straightforward:

{
    retries: number of times to retry,
    retryOn: [array of status codes],
    retryFn?: async function to execute between each retry
    retryTimeout?: ms to wait in between retries (sensible default - like 1000ms, ignored if retryFn is supplied)
}

The only tricky parts were those you pointed out - don't retry if the AbortController.signal.aborted === true

The retryFn was especially helpful because it allows the user to do absolutely anything they want (like refresh JWT) in between retries.

Would an API like this work?

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024

I like the simplicity of that - but I think that you could eliminate retryOn and have that logic be up to the user in retryFn. Then we could make a default retryFn that checks against isRetryAllowed was true OR if status code was 429, 502, 503, or 504, AND ALSO checks against the Retry-After header if it existed.

from frisbee.

antgel avatar antgel commented on June 11, 2024

Great to see the activity around here! :) I don't mind that #86 was closed in favour of this, but does the above issue description include relevant details to handle that scenario? (Retrying a request after refreshing JWT access token.)

from frisbee.

antgel avatar antgel commented on June 11, 2024

Oops, I missed it, it was in #92 (comment). :)

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024

We should also use https://github.com/sindresorhus/p-queue to create a queue of requests that can be processed.

from frisbee.

niftylettuce avatar niftylettuce commented on June 11, 2024

What's left:

  • Write tests for timeout
  • Write tests for retry
  • Try to get 100% code coverage
  • Any instance of polyfill.io need to have proper listing of polyfills (e.g. 38d2252#diff-eacf331f0ffc35d4b482f1d15a887d3bR15 is empty right now)
  • Ensure timeout, retry, retryStatusCodes, retryMethods, retryAfterStatusCodes, handleRetry are documented
  • There is a queue option I added but it's not being used, so either remove that or add support for queue (e.g. via https://github.com/sindresorhus/p-queue)

from frisbee.

Related Issues (20)

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.