perf(utils): ignore stale useFetch responses#539
Closed
JustYannicc wants to merge 1 commit into
Closed
Conversation
Collaborator
Author
|
Superseded by consolidated upstream PR #555. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
useFetchso older in-flightwindow.electron.httpRequestresponses cannot update data, errors, loading state, or callbacks after a newer request starts.executeflips false or the hook unmounts.revalidateresponses and function URL request-input changes.Why
Rapid
revalidate, pagination, or request-input changes can leave multiple HTTP requests in flight. Before this patch, an older response could resolve after a newer run and overwrite newer data or invoke stale callbacks.Compatibility impact
useFetchreturn shape and option names are unchanged.How tested
node --test scripts/test-use-fetch-stale-runs.mjsfailed before the hook change because stale data overwrote the latest result, and a changed function URL request input did not start a second request.node --test scripts/test-use-fetch-stale-runs.mjspasses on this PR branch.node --test scripts/test-use-fetch-stale-runs.mjs scripts/test-abortable-promise-hooks.mjs scripts/test-menubar-storage-remounts.mjs scripts/test-raycast-cache-size-index.mjspassed 20 tests.origin/mainyet, so the focuseduseFetchtest was rerun here.src/renderer/src/raycast-api/hooks/use-fetch.ts.Stack validation
Draft until the consolidation stack lands. This targets upstream
mainand depends on #530, #531, #532, #533, #534, and #535.