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

Invalid Hook call in dynamic routes #607

Closed
kush-daga opened this issue Aug 20, 2021 · 16 comments
Closed

Invalid Hook call in dynamic routes #607

kush-daga opened this issue Aug 20, 2021 · 16 comments
Labels
priority: medium type: bug code to address defects in shipped code

Comments

@kush-daga
Copy link

Describe the bug
In my next.js website, the dynamic routes, are throwing an error.

image

These work fine locally, and give no errors.
This can be related to using of esbuild as node_bundler.

Expected behavior
The dynamic routes should work, as they do locally.

Versions

  • Next.js: ^10.2.0
  • plugin (if installed at fixed version):

If you're using the CLI to build

  • OS: [e.g. macOS, Windows]
  • netlify/cli version:

If you're using file-based installation

  • netlify.toml:
    image
@kush-daga
Copy link
Author

Definitely seems like a netlify plugin issue, as tested the same by deploying on vercel, and it works as expected

@lindsaylevine lindsaylevine added status: needs reproduction this issue needs to provide a repo that reproduces the bug described priority: medium type: bug code to address defects in shipped code labels Aug 23, 2021
@lindsaylevine
Copy link
Contributor

@kush-daga hey! thanks for reporting this to us! can you please provide a simple and deployable repo that reproduces your issue? it can have just a single failing dynamic page. thank you!

@kush-daga
Copy link
Author

kush-daga commented Aug 24, 2021

@kush-daga hey! thanks for reporting this to us! can you please provide a simple and deployable repo that reproduces your issue? it can have just a single failing dynamic page. thank you!

Heyy! Thanks for your reply, I did recreate this issue,

This is the url -> https://romantic-gates-22561a.netlify.app/dynamic/1
GitHub Repo -> https://github.com/kush-daga/next-netlify-bug

Works perfectly on local
image

@kush-daga
Copy link
Author

kush-daga commented Aug 24, 2021

Also I have the NETLIFY_EXPERIMENTAL_PROCESS_DYNAMIC_IMPORTS set totrue in my netlify env variables

@lindsaylevine lindsaylevine removed the status: needs reproduction this issue needs to provide a repo that reproduces the bug described label Aug 24, 2021
@lindsaylevine
Copy link
Contributor

hey @kush-daga! switching to target: serverless from target: experimental-serverless-trace should fix your issue. let me know and we can close :)!

@lindsaylevine
Copy link
Contributor

lindsaylevine commented Aug 24, 2021

and ftr, the NETLIFY_EXPERIMENTAL_PROCESS_DYNAMIC_IMPORTS flag is no longer needed for esbuild to work with dynamic imports!

@kush-daga
Copy link
Author

hey @kush-daga! switching to target: serverless from target: experimental-serverless-trace should fix your issue. let me know and we can close :)!

Hey, umm I wanted to do this, however I am using sentry in my app, which requires this mode of target, as per this comment getsentry/sentry-javascript#3621 (comment)

@lindsaylevine
Copy link
Contributor

hmm. i pinged our esbuild expert internally to see what might be up. in the meantime, is it possible to omit one of the three offending features? (aka e-s-t, esbuild, or sentry?) or are all three required for your use case?

note that we will "soon" be moving off of target: serverless to target: server. not in the very near future, but eventually.

@kush-daga
Copy link
Author

hmm. i pinged our esbuild expert internally to see what might be up. in the meantime, is it possible to omit one of the three offending features? (aka e-s-t, esbuild, or sentry?) or are all three required for your use case?

note that we will "soon" be moving off of target: serverless to target: server. not in the very near future, but eventually.

Hmmm, I wish i could omit one, but seems like all three are required for now, thanks for the reply though, will be waiting on an update :)

@ascorbic
Copy link
Member

Hi @kush-daga
I managed to reproduce this issue. Removing next from external node modules fixes it for me. Was there a reason you needed to add it? Let me know if it works for you.

@ascorbic
Copy link
Member

Ah, I realise the error message was suggesting it. We will fix that. To be clear: you shouldn't add next to external node modules, whatever the message says.

@sidwebworks
Copy link

any update on this? I am struggling to deploy this on netlify, it works fine on vercel but my entire stack is on netlify so I wanna build there

@lindsaylevine
Copy link
Contributor

@SidRathi47 my teammate matt provided updates earlier in the day. also, there are two solutions listed in the comments so far:

  1. remove next from external_node_modules if you have it in your netlify.toml (like kush-daga)
  2. change to target: serverless

we know nothing about your specific use case as you've only just commented. do those updates and solutions not suffice for you? what further update are you looking for?

@kush-daga
Copy link
Author

Hi @kush-daga
I managed to reproduce this issue. Removing next from external node modules fixes it for me. Was there a reason you needed to add it? Let me know if it works for you.

Hey, sorry was a bit busy, will check and get back on this asap.

@kush-daga
Copy link
Author

Hey! just checked, removing next from external node modules fixed it. Thank you so much @ascorbic, @lindsaylevine

@lindsaylevine
Copy link
Contributor

yay, thanks for letting us know!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

4 participants