Skip to content
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

Dynamic href prints console warning in development mode #16794

Closed
ztanner opened this issue Sep 2, 2020 · 9 comments · Fixed by #16798
Closed

Dynamic href prints console warning in development mode #16794

ztanner opened this issue Sep 2, 2020 · 9 comments · Fixed by #16798
Milestone

Comments

@ztanner
Copy link
Member

ztanner commented Sep 2, 2020

Bug report

Describe the bug

When using the new support (v9.5.3) for dynamic href (ie, <Link href="/pages/1"> when referring to pages/[id].js, a warning is printed to the console:

Unknown key passed via urlObject into url.format: searchParams

To Reproduce

Here's a minimal repro: https://github.com/ztanner/next-dynamic-link-bug -- run yarn dev and observe the console on the index page.

Expected behavior

No warnings should be printed

Screenshots

Dropping a debugger in the validator:
CleanShot 2020-09-02 at 11 23 19@2x

Additional context

The validation is coming from this section: https://github.com/vercel/next.js/blob/canary/packages/next/next-server/lib/router/router.ts#L566-L573 which implies searchParams is potentially valid URL option, and shouldn't be a warning?

Happy to jump on a solution to this - just want to verify that either searchParams is valid, or alternatively it can be plucked out before being sent to the validator.

@ztanner ztanner changed the title Dynamic href prints console in development mode Dynamic href prints console warning in development mode Sep 2, 2020
@ijjk ijjk added the kind: bug label Sep 2, 2020
@Timer Timer added this to the iteration 8 milestone Sep 2, 2020
@bogdansoare
Copy link

Also having this issue

@kodiakhq kodiakhq bot closed this as completed in #16798 Sep 3, 2020
kodiakhq bot pushed a commit that referenced this issue Sep 3, 2020
Fixes a warning being logged to the console when using `href` with a dynamic path. Fixes #16794
@styxlab
Copy link
Contributor

styxlab commented Sep 15, 2020

Also having this issue. Closed but not fixed?

@balazsorban44
Copy link
Member

@styxlab I just checked, it is fixed on [email protected]. Either upgrade to canary, or wait until it gets to stable 9.5.4

@bawdeveloppement
Copy link

I think this can solve your problem, tell me if the solution work

@tobyhinloopen
Copy link

tobyhinloopen commented Sep 24, 2020

I confirm this is fixed in 9.5.4. I changed mine to "next": "9.5.4-canary.21", in package.json

(edit for search travellers: canary versions contain bugs. beware. also, it updates almost daily. expect quick bugfixes. checkout the latest version here: https://www.npmjs.com/package/next?activeTab=versions )

@yunyong
Copy link

yunyong commented Sep 26, 2020

You can use it without warning like this :
<Link href="/pages/[id]" as="/pages/1">

as is the path that will be rendered in the browser URL bar.

HitoriSensei pushed a commit to HitoriSensei/next.js that referenced this issue Sep 26, 2020
Fixes a warning being logged to the console when using `href` with a dynamic path. Fixes vercel#16794
@mohdsauood
Copy link

mohdsauood commented Sep 29, 2020

I confirm this is fixed in 9.5.4. I changed mine to "next": "9.5.4-canary.21", in package.json

@tobyhinloopen can you tell me how to upgrade from '9.5.3' to '9.5.4-canary.21' without breaking anything ?

  • npm outdated didn't help
  • npm i [email protected] led to error Could not find files for / in .next/build-manifest.json
    Could not find files for / in .next/build-manifest.json

@tobyhinloopen
Copy link

tobyhinloopen commented Sep 30, 2020

I confirm this is fixed in 9.5.4. I changed mine to "next": "9.5.4-canary.21", in package.json

@tobyhinloopen can you tell me how to upgrade from '9.5.3' to '9.5.4-canary.21' without breaking anything ?

  • npm outdated didn't help
  • npm i [email protected] led to error Could not find files for / in .next/build-manifest.json
    Could not find files for / in .next/build-manifest.json

Note that the canary versions do contain bugs. npm outdated doesn't help because I suppose it doesn't upgrade to beta/alpha versions. (I assume that's what canary is)

You can try to destroy all temporary files (basically anything that can be generated) and try a clean start. You can destroy everything not tracked into source control using:

# warning: this will delete EVERYTHING not in source control
git clean -fdx
# end of warning

I upgraded by putting "next": "9.5.4-canary.23", in my package.json and running npm i or yarn install

DarrenTsung added a commit to DarrenTsung/next_js_tutorial that referenced this issue Oct 3, 2020
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants