serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

"hostname" and "port" must be provided when starting next to use "unstable_revalidate"

Open marconucara opened this issue 2 years ago • 4 comments

Issue Summary

I want to use req.unstable_revalidate for ISG. Reading here it seems supported.

Actual behavior

If I call req.unstable_revalidate inside an api I got this error:

"hostname" and "port" must be provided when starting next to use "unstable_revalidate". See more here https://nextjs.org/docs/advanced-features/custom-server

I can't get any actual information about this problem at the provided url. Also, checking the code generated inside .next/serverless/chunk/ I don't think I can pass hostname and port parameters, because the function accept only one parameter:

apiRes.unstable_revalidate = (urlPath)=>unstable_revalidate(urlPath, req, apiContext)

Looking for the round of calls that are made previously, I don't even seem to be able to modify this apiContext.

(Locally works fine)

Versions

  • OS/Environment: macOS 12.2.1
  • @sls-next/serverless-component version: v3.7.0-alpha.11
  • Next.js version: 12.1

Checklist

  • [x] You have reviewed the README and FAQs, which answers several common questions.
  • [x] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • [x] You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

marconucara avatar Mar 14 '22 21:03 marconucara

AFAIK base ISR feature is working where you add the revalidate prop to getStaticProps. If you are referring to 12.1 release's On-demand Incremental Static Regeneration, it should not be working.

agnese-kerubina avatar Mar 15 '22 13:03 agnese-kerubina

So this happen to me if I am using a custom server, if you do then make sure you have const app = next({ dev, hostname, port }) with hostname and port

check https://nextjs.org/docs/advanced-features/custom-server for more info

thmohd avatar Mar 23 '22 02:03 thmohd

@thmohd I am using Serverless Stack (sst) which uses serverless-next.js, maybe I should open an issue to them? Can you confirm that ISG with unstable_revalidate should work on the serverless-next.js side?

(I do not create any custom server and it is not clear to me if the custom server is created by sst or by serverless-next.js)

marconucara avatar Mar 23 '22 14:03 marconucara

AFAIK base ISR feature is working where you add the revalidate prop to getStaticProps. If you are referring to 12.1 release's On-demand Incremental Static Regeneration, it should not be working.

Hi, Do you know if there is any plan to add this feature?

chandank-nu avatar Mar 25 '22 11:03 chandank-nu

AFAIK base ISR feature is working where you add the revalidate prop to getStaticProps. If you are referring to 12.1 release's On-demand Incremental Static Regeneration, it should not be working.

Hi, Do you know if there is any plan to add this feature?

Any update?, trying to use On-demand ISR gives me "Invariant: required internal revalidate method not passed to api-utils"

Lea23VC avatar Nov 22 '22 19:11 Lea23VC