fix(useSearchParams): cancel debounce before navigation - #430
Open
ejsmith wants to merge 1 commit into
Open
Conversation
|
ejsmith
marked this pull request as ready for review
August 10, 2026 02:01
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.
Summary
useSearchParamsdebounce timer when SvelteKit navigation beginsfilter=stale, navigates in-app tofilter=fresh, and verifies the old timer cannot overwrite the destination URLWhy
The existing debounce cleanup runs only when the component is destroyed. SvelteKit can navigate while reusing the same route component, leaving the old timer alive. When it fires after the navigation, it can write stale search parameters back onto the new URL.
Registering the same cleanup with
beforeNavigatecloses that race before the destination navigation starts.Validation
pnpm -F runed checkpnpm -F runed exec vitest --run(246 tests)pnpm -F runed exec playwright test src/lib/utilities/use-search-params/use-search-params.scenarios.spec.ts --workers=1(99 tests)pnpm lint