Only one request would actually be made to the server. Internally, the promise from the first axios.get('http://localhost:8080') would be shared across all of these calls.
Coverage remained the same at 100.0% when pulling c609f2b1f7ff67b8a9f55c51209e9a83324d1127 on bugfix/55/never-cache-cancelled-requests into 95e14b5e6f1a0aa95b45ae2ef8e471f639736379 on master.
Coverage remained the same at 100.0% when pulling c609f2b1f7ff67b8a9f55c51209e9a83324d1127 on bugfix/55/never-cache-cancelled-requests into 95e14b5e6f1a0aa95b45ae2ef8e471f639736379 on master.
Fixes #55
Cause
A mechanism was added in 0368696eb8f7a9181e37adef6d19e05bee7a5aab to prevent sending duplicate identical requests.
If there was a server running this:
And a user did this:
Only one request would actually be made to the server. Internally, the promise from the first
axios.get('http://localhost:8080')
would be shared across all of these calls.This runs into issues once
cancelTokens
are introduced (#55). Although Cachios stops sharing these promises once they're rejected, code that:Runs before the Cachios reject handler has been fired:
Output:
Workaround
We can avoid this issue by disabling the sharing of unresolved cancellable requests. Requests that provide a
cancelToken
property in their request config will never share their promise or use a shared promise.