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

Resolve race condition #21

Open
jason89521 opened this issue May 24, 2023 · 4 comments
Open

Resolve race condition #21

jason89521 opened this issue May 24, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@jason89521
Copy link
Owner

There are two case of the race condition.

  • The response returned from request is after the user mutating the model.
  • Suppose useInfiniteFetch fetch a post list with id from 1 to 10, and useFetch fetch the post with id 1 later. But the response from useFetch may be in front of the response from useInfiniteFetch. In this case, we will update the model with expired response.
@jason89521
Copy link
Owner Author

For the first case, we can abort the ongoing request and call the revalidate again. For the second case, I haven't figured out a solution.

@jason89521
Copy link
Owner Author

It seems that we cannot resolve the second case because the model is defined from the user. However, we can pass the start time to the syncModel method such that the user can determine which data is expired.

@jason89521 jason89521 added the enhancement New feature or request label May 27, 2023
@jason89521
Copy link
Owner Author

It may be good if pagination adapter can record the timestamp. However, I need to be careful not to make the API too complex, or else it would be counterproductive.

@jason89521
Copy link
Owner Author

In the second case, if the API for the post list is newer than the API for getting a single post, discarding the "get post" API may result in receiving incomplete data. This is because the list API usually does not return complete information. I might need to abandon this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant