-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Description
What version of Next.js are you using?
10.0.4
What version of Node.js are you using?
14.15.4
What browser are you using?
Chrome
What operating system are you using?
Windows 10/Alpine Linux
How are you deploying your application?
next start
Describe the Bug
When returning a redirect value from getStaticProps in a dynamic route, the IncrementalCache.set function attempts to write invalid html data to the static page cache.
Node.js version 14+ throws an exception here, which triggers this warning:
Failed to update prerender files for <pathname> TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
After downgrading to node version 12.18.4, no error occurs, instead an html file containing [object Object]
is written.
In our use case, there are no apparent ill effects with either version, aside from a large amount of entries in our error logs for the node.js 14 variant. Redirects still work as expected.
Expected Behavior
Html-cache should probably not be (attempted) generated from redirected paths.
To Reproduce
- Clone this repo https://github.com/anders-nom/nextjs-ssg-redirect-cache-bug
- Install and use Node.js version 14.15.4
- Delete the .next directory if it exists
npm run build
npm run start
- Visit http://localhost:3000/redirect
- Observe the aforementioned warning in the server console, and note that no redirect.html or redirect.json was generated in /.next/server/pages