Skip to content

[🐞] Qwik 1.9.0 holds onto searchParams when redirecting from a server action #6926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandonpittman opened this issue Oct 1, 2024 · 7 comments
Labels
COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it TYPE: bug Something isn't working

Comments

@brandonpittman
Copy link
Contributor

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

@brandonpittman brandonpittman added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Oct 1, 2024
@brandonpittman
Copy link
Contributor Author

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?

@wmertens
Copy link
Member

wmertens commented Oct 1, 2024

@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?

@brandonpittman
Copy link
Contributor Author

brandonpittman commented Oct 1, 2024

@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

@brandonpittman
Copy link
Contributor Author

brandonpittman commented Oct 1, 2024

@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

@thejackshelton thejackshelton added COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it WAITING FOR: team Waiting for one of the core team members to review and reply STATUS-2: team is working on this Scheduled for work by the core team and removed STATUS-1: needs triage New issue which needs to be triaged WAITING FOR: team Waiting for one of the core team members to review and reply STATUS-2: team is working on this Scheduled for work by the core team labels Oct 1, 2024
@brandonpittman
Copy link
Contributor Author

Pretty sure this is what broke things:

#6778

@brandonpittman
Copy link
Contributor Author

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

@brandonpittman
Copy link
Contributor Author

brandonpittman commented Oct 6, 2024

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

#6927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it TYPE: bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants