cancel old graphql requests when new ones are run #8238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reports are run one of two ways via the UI:
/reports
, choosing items from the dropdown inputs, and hitting the "Run Report" button/reports/subjects/:id
Either way, it does a GraphQL lookup and the page waits for it to return a value. If you use method 1, and click the button before an existing request is done, it queues it, which can lead to potential long network requests running in the background, especially if you run a long report a bunch of times for either impatience or debugging reasons.
The ideal way to fix this is to improve the searches themselves so that they don't take so long. In the meantime, making sure new requests invalidate old requests is helpful.
This can be done by changing the method from an
async func()
call to anember-concurrency
-stylefunc = task(async() {})
call, which fixes the issue in case 1 (case 2 doesn't need a fix because you can't re-run the report fromReportsSubjectRoute
).However, there are still two cases that aren't yet covered:
/reports
, choosing items from the dropdown inputs, hitting the "Run Report" button, and then hitting the "Cancel" button./reports/subjects/:id
...and then clicking the "Back to Reports" link (or simply clicking back in the browser or somewhere else in the app).I think I can figure both of these out, but need more time ;P