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

Cached query doesn't abort uncached resulting in race conditions #498

Open
SQReder opened this issue Aug 18, 2024 · 0 comments
Open

Cached query doesn't abort uncached resulting in race conditions #498

SQReder opened this issue Aug 18, 2024 · 0 comments
Labels
scope:core type:bug Something isn't working
Milestone

Comments

@SQReder
Copy link
Contributor

SQReder commented Aug 18, 2024

If query started with cached parameters it doesn't abort running uncached query

const cachedQuery = createQuery({ 
  handler() {
    const ac = new AbortController();

    onAbort(() => {
      ac.abort("early aborted");
    });

    ...
  }
})

concurrency(cachedQuery, { strategy: "TAKE_LATEST" });
cache(cachedQuery, { staleAfter: "1m" });


cachedQuery.start('1st'); // long query that will be cached
/// wait for complete ...
cachedQuery.start('2nd'); // long query that should be aborted
// start cached query before 2nd resolved
cachedQuery.start('1st'); // completes almost immediately but doesnt abort 2nd

Reproduce https://github.com/SQReder/farfetched-cache-issues

@igorkamyshev igorkamyshev added type:bug Something isn't working scope:core labels Aug 21, 2024
@igorkamyshev igorkamyshev added this to the v1.0 milestone Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:core type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants