Skip to content

Cache error on redirects from dynamic routes with SSG [Node.js 14+] #20816

@anders-nom

Description

@anders-nom

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions