Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: cloning do not work correctly with concurrency requests #899

Closed
bupy7 opened this issue Sep 18, 2024 · 3 comments · Fixed by #921
Closed

Bug: cloning do not work correctly with concurrency requests #899

bupy7 opened this issue Sep 18, 2024 · 3 comments · Fixed by #921
Assignees
Labels
bug Something isn't working triage Needs triage

Comments

@bupy7
Copy link

bupy7 commented Sep 18, 2024

What happened?

Cloning do not work correctly with concurrency request: https://codesandbox.io/p/sandbox/j9cfcl

In this example I have changed "name" property in the request with "0" index key. Every next requests persist this change.

This is not happen if request do sequentially. To reproduce behavior - try runSequentially() and runSpreadly() functions in the code example.

axios-cache-interceptor version

v1.6.0

Node / Browser Version

any browser

Axios Version

v1.7.7

What storage is being used

Memory Storage

Relevant debugging log output

Everything you can take in the Codesandox example.
@bupy7 bupy7 added bug Something isn't working triage Needs triage labels Sep 18, 2024
@bupy7
Copy link
Author

bupy7 commented Sep 18, 2024

Workaround:

import axios from "axios";
import { buildMemoryStorage, setupCache } from "axios-cache-interceptor/dev";

const cachedAxios = setupCache(axios.create(), {
  storage: buildMemoryStorage(false),
});

cachedAxios.interceptors.response.use((v) => {
  return {
    ...v,
    data: v.data !== undefined ? JSON.parse(JSON.stringify(v.data)) : undefined,
  }
})

@arthurfiorette
Copy link
Owner

HI @bupy7, thanks for opening this request.

Would you want to open a PR? remember to add unit tests.

Taking a look at our existing unit tests is a good way to start and learn how its done.

@arthurfiorette arthurfiorette linked a pull request Oct 18, 2024 that will close this issue
@arthurfiorette
Copy link
Owner

Fixed in v1.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants