relay-tools / react-relay-network-layer

ReactRelayNetworkLayer with middlewares and query batching for Relay Classic.
MIT License
277 stars 47 forks source link

Refresh token executed multiple times, when one time should be enough #25

Closed alexxv closed 7 years ago

alexxv commented 7 years ago

Hey,

We have a scenario, where multiple concurrent requests receive HTTP 401, because authentication token is expired. Every one of those triggers a refreshToken flow, thus we have multiple refreshes concurrently.

I think it should there should be only one refreshToken promise running simultaneously,

What do you think?

If you think it's worth adding, I'll be glad to submit a PR with this. I've implemented this kind of solution for our app, it's very simple

Alex

nodkz commented 7 years ago

Cool. Will glad to accept your PR!

Cause client is one, token is also one, so only one refreshToken call will cover 99% of use cases.

nodkz commented 7 years ago

@alexxv if you have no time for PR, maybe you can share your code?

alexxv commented 7 years ago

@nodkz

alexxv commented 7 years ago

sorry, accidentally closed the issue

alexxv commented 7 years ago

@nodkz I've open a PR #32, take a look, lmk what you think

nodkz commented 7 years ago

Awesome. Super simple and useful solution. Thanks a lot!