Next.js Discord

Discord Forum

Self hosted application randomly started trying to ISR dynamic pages

Unanswered
Pharaoh Hound posted this in #help-forum
Open in Discord
Avatar
Pharaoh HoundOP
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

1 Reply

Avatar
Pharaoh HoundOP
oh and I guess it might be helpful to add my nextjs version: 14.2.3