-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix(discover): Should reload when payload changes while loading #28653
fix(discover): Should reload when payload changes while loading #28653
Conversation
If the eventView changes while the request is in-flight/loading, we should cancel the in-flight request and fetch again. This is problematic in cases where the request takes a little longer to load and the user changes the query while it is still in-flight. If a reload is not triggered at this time, the results are actually incorrect since it's showing the results from the previous (stale) in-flight request.
// clear any inflight requests since they are now stale | ||
api.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have the potential to cancel other requests unintentionally? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cancellation only occurs for the Client
instance of api
. Not other Client
instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically it depends on how you pass in api
, I think perhaps we should make these instances unique now with useAPI()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that you'd audited the api props, 👍
If the eventView changes while the request is in-flight/loading, we should cancel the in-flight request and fetch again. This is problematic in cases where the request takes a little longer to load and the user changes the query while it is still in-flight. If a reload is not triggered at this time, the results are actually incorrect since it's showing the results from the previous (stale) in-flight request.
If the eventView changes while the request is in-flight/loading, we should
cancel the in-flight request and fetch again. This is problematic in cases where
the request takes a little longer to load and the user changes the query while
it is still in-flight. If a reload is not triggered at this time, the results
are actually incorrect since it's showing the results from the previous (stale)
in-flight request.