#Self hosted application randomly started trying to ISR dynamic pages

2 messages · Page 1 of 1 (latest)

sleek echo
#

I self host NextJS on ECS Fargate, and at some point my application triggered ISR and then the server gets stuck in a broken state. I don't use ISR at all and am only seeing this in a single environment and haven't been able to find steps to reproduce, but essentially you start to see this in the logs:

Route / couldn't be rendered statically because it used cookies. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

and then the server tries to update the filesystem cache:

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFile (node:internal/fs/promises:992:5)
    at Object.writeFile (/app/init/node_modules/dd-trace/packages/datadog-instrumentations/src/fs.js:264:57)
    at Object.writeFile (/app/node_modules/next/dist/server/lib/node-fs-methods.js:21:45)
    at FileSystemCache.set (/app/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js:256:27)
    at async IncrementalCache.set (/app/node_modules/next/dist/server/lib/incremental-cache/index.js:411:13)
    at async /app/node_modules/next/dist/server/response-cache/index.js:121:25
    at async /app/node_modules/next/dist/lib/batcher.js:45:32

The thing I can't wrap my head around is I have been running app router for over a year, have never seen this issue, and 100% of my pages in my application are dynamically rendered. I don't have force-dynamic on any routes, but I can verify the container running was built with each page bundle as dynamic. I feel like this is a bug in NextJS that somehow got into a weird state and then tried to static compile routes that are dynamic, but I really have no idea.

I've seen one other person on Github experience this with a similar deployment setup, but they didn't respond with a fix or cause: https://github.com/vercel/next.js/discussions/68174

GitHub

Summary With international traffic enabled we occasionally see high levels of traffic that we suspect to be security scans. During these periods we eventually start seeing Invariant: expected pageD...

oblique harborBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)