Skip to content

feat(useSearchParams): remove trailing question mark#561

Open
zsugabubus wants to merge 10 commits intomolefrog:v3from
zsugabubus:no-question-mark
Open

feat(useSearchParams): remove trailing question mark#561
zsugabubus wants to merge 10 commits intomolefrog:v3from
zsugabubus:no-question-mark

Conversation

@zsugabubus
Copy link
Copy Markdown

No description provided.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@zsugabubus
Copy link
Copy Markdown
Author

Initial test failure seemed unrelated. I attempted to track it down and I found lot's of flaky tests. After a hundred bun test --randomize iterations I think I've managed to fix everything. Should I open a separate PR?

@molefrog
Copy link
Copy Markdown
Owner

molefrog commented Apr 6, 2026

hi @zsugabubus thanks for the PR!
could you summarise what was the issue you fixed here and the flaky tests?

@zsugabubus
Copy link
Copy Markdown
Author

I use useSearchParams hook to manage some state in the search string. Given /path?search=hello. When user clears the search input, I skip appending the search param because it looks dumb (/path?search=), so I just do a prev.delete("search") within the setter. However, the resulting URL will be /path? (I would expect /path) because the question mark remains there unconditionally.

In the added test, I set no search params and it would be https://wouter.dev/? without the modifications.

Regarding the tests, I saw symptoms of missing unmounts (e.g. multiple links/elements found), missing act warnings, and the most tricky was that a history.back() from a previous test could affect a later history.pushState+history.length check.

@zsugabubus
Copy link
Copy Markdown
Author

No, sorry. The most tricky was that bun test --seed (IIRC) is affected by file modification timestamp/inode number/directory listing order (???). So even though I had the seed number from --randomize or without randomization I just had a failing test, I saved the test file and the failure magically disappeared on the next run and I could get a completely new, unrelated error. It kept me a while until I realized it.

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.

2 participants