Skip to content

fix(useSearchParams): cancel debounce before navigation - #430

Open
ejsmith wants to merge 1 commit into
svecosystem:mainfrom
ejsmith:agent/cancel-debounced-search-param-navigation
Open

fix(useSearchParams): cancel debounce before navigation#430
ejsmith wants to merge 1 commit into
svecosystem:mainfrom
ejsmith:agent/cancel-debounced-search-param-navigation

Conversation

@ejsmith

@ejsmith ejsmith commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • cancel a pending useSearchParams debounce timer when SvelteKit navigation begins
  • retain the existing component-teardown cleanup
  • add a browser regression that queues filter=stale, navigates in-app to filter=fresh, and verifies the old timer cannot overwrite the destination URL

Why

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 beforeNavigate closes that race before the destination navigation starts.

Validation

  • pnpm -F runed check
  • pnpm -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

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 23eb766

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ejsmith
ejsmith marked this pull request as ready for review August 10, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant