QwikDev/qwik

[๐Ÿž] Qwik 1.9.0 holds onto searchParams when redirecting from a server action

brandonpittman opened this issue ยท 7 comments

Which component is affected?

Qwik City (routing)

Describe the bug

Through 1.8.0, our app would successfully redirect from server actions to some URL like /profile from the front page of the app. The front page takes an ?id=XXX param to get some data and then after tapping a consent button, it runs an action, saves data to a cookie and throws a redirect.

It used to drop the search params when redirecting. Since 1.9.0, it holds onto the search params.

Reproduction

https://stackblitz.com/edit/github-cv95eb?file=src%2Froutes%2Findex.tsx

Steps to reproduce

No response

System Info

System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 63.16 MB / 16.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 18.20.3 - ~/Library/pnpm/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.7.0 - ~/Library/pnpm/npm
    pnpm: 9.4.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 129.0.6668.60
    Safari: 18.1
    Safari Technology Preview: 18.0
  npmPackages:
    @builder.io/qwik: 1.9.0 => 1.9.0
    @builder.io/qwik-city: 1.9.0 => 1.9.0

Additional Information

No response

Seems related to this:

https://github.com/QwikDev/qwik/pull/6778/files#diff-6c570481bf47bb1dae75e8d12166dc67e7ed94954b9714816b7378813b20a24d

But if this is what the team thinks should be the correct behavior, how can I drop the searchParams?

@brandonpittman can you provide a repro so we're talking about the same things? I thought that change was to provide search parameters when calling actions?

@wmertens

The Stackblitz link above shows this behavior:

If you submit a form from a page with searchParams and redirect in the action, the page you get redirected to has the previous pageโ€™s searchParams even though the redirect was to a route with no searchParams.

This only started with 1.9.0.

Here's a recording showing the problem (includes audio).

searchParams.issue.720.mov

@wmertens Just for completeness, here's another Stackblitz (with recording) pinned at 1.8.0 where redirects don't hold onto the submitting page's searchParams.

https://stackblitz.com/edit/github-cv95eb-7l9fik?file=package.json

Screen.Recording.2024-10-01.at.3.36.23.PM.mov

Pretty sure this is what broke things:

#6778

Another problem is that if you redirect to a URL with searchParams, Qwik drops the params in the URL you try to redirect to.

I created a PR. Can someone take a look at it, please?

#6927