Prod server works fine for a time and then silently returns no response
Unanswered
Lilac posted this in #help-forum
LilacOP
I can't keep restarting the server just to keep it working lol
curl response from docker container (using https://github.com/vercel/next.js/blob/canary/examples/with-docker-multi-env/docker/production/Dockerfile):
nothing useful from nextjs itself:
I use the same config and all for another nextjs container and it works perfectly fine. The nextjs site in question doesn't do anything crazy. Just fetches some JSON and renders it.
curl response from docker container (using https://github.com/vercel/next.js/blob/canary/examples/with-docker-multi-env/docker/production/Dockerfile):
curl -v http://localhost:9001
* Trying 127.0.0.1:9001...
* Connected to localhost (127.0.0.1) port 9001 (#0)
> GET / HTTP/1.1
> Host: localhost:9001
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 304 Not Modified
< Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
< x-nextjs-cache: HIT
< X-Powered-By: Next.js
< Cache-Control: s-maxage=3600, stale-while-revalidate
< ETag: "rln3m3yjfrwpc"
< Content-Type: text/html; charset=utf-8
< Content-Length: 42385
< Date: Thu, 26 Oct 2023 03:26:41 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
* Connection #0 to host localhost left intactnothing useful from nextjs itself:
â–² Next.js 13.5.6
- Local: http://80ca70ebdd4c:3000
- Network: http://172.20.0.2:3000
✓ Ready in 306msI use the same config and all for another nextjs container and it works perfectly fine. The nextjs site in question doesn't do anything crazy. Just fetches some JSON and renders it.
43 Replies
LilacOP
I've moved my deployment to vercel in the mean time but I'd still like help debugging my container - can't wait to find it breaks on vercel too lol
why doesn't nextjs emit any logs in prod unless you're using vercel and it's web interface??
LilacOP
Digital ocean right next to an identical container that doesn’t suffer any issues
@Lilac why doesn't nextjs emit any logs in prod unless you're using vercel and it's web interface??
It should still log errors in the container
@Lilac Digital ocean right next to an identical container that doesn’t suffer any issues
Are there any errors on the digital ocean side? There's lots of other things that could cause it to shut down
LilacOP
as posted in my original question, the nextjs server responds but doesn't send any data. the container doesn't error out (therefore it doesn't restart). i have other containers running adjacent in the same vm with no issues, including another almost identical nextjs project. there are no other logs other than that which i also posted above.
Masai Lion
Smells like a cache issue or something related to handling the request can you show the code or explain where and how do you fetch the data and then the serving of it?
LilacOP
even if that were true, the server would still respond to a http request with a content of a length, would it not?
Masai Lion
So in rsc with the build in fetch or with a custom adapter, ORM ?
LilacOP
you'll need to dumb that question down for me a bit haha
so i have a page.tsx at the root of the app directory that looks like this
async function getData() {
const response = await fetch('https://api/', { next: { revalidate: 3600 } });
const data = await response.json();
return data as Promise<Data>;
}
export default async function IndexPage() {
const { items } = await getData();
return some jsx using the data
}Masai Lion
Lol I'm also a dumb mofo don't get flattened hahah. In a react server component using the fetch api or something else like axios, or a db
Try setting cache: no-store
And test it out also to check loggs you can type out console.error instead if console.log at the parts where ya handling the data
LilacOP
okay but any other suggestions? i'm hesitant to do anything that restarts the server unless i'm confidant it's likely as then i'll need to wait for it to break again at a seemingly random interval
as i said, it works for a time
sometimes days
i'll check in by loading the page up
and then it just gives up working
and there's never any useful logs
Masai Lion
Issues like that are hard to debugg idd
LilacOP
and nothing in the docs specifying how to increase the logging level for prod
it's infuriating
Masai Lion
When the app 'breaks' did you try opening an incognito tab and access the page?
LilacOP
yep
but that's no better than using curl
Masai Lion
Idd you are right I forgot that u posted that initially who's the dumbo now?

Last question the fetch request is to an external endpoint or to the build in next js api of the app?
LilacOP
semi external endpoint (an adjacent container running direcus, a headless cms). again, the same api my other nextjs project fetches lol
Masai Lion
Yeah your setup looks a lot like mine for my personal projects I'm using a vps service and just hosting everything inside docker containers (caprover paas). I build myself a headless cms where my other sites are fetching the contents from it I rly had no issues like yours. My db is hosted on the vps itself tho.
All of the above uses next js
LilacOP
true well i'm giving up and I've added some console logs
a log before and after the fetch inside the getdata function
Masai Lion
Sorry I couldn't help ya more mate
LilacOP
np computers suck gonna take up professional gardening
container recreated.
restart the clock.gif
curl -v http://localhost:9001
* Trying 127.0.0.1:9001...
* Connected to localhost (127.0.0.1) port 9001 (#0)
> GET / HTTP/1.1
> Host: localhost:9001
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
< x-nextjs-cache: HIT
< Cache-Control: s-maxage=3600, stale-while-revalidate
< ETag: "3hehgoqvfswst"
< Content-Type: text/html; charset=utf-8
< Content-Length: 42510
< Date: Thu, 26 Oct 2023 05:44:13 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="image" hre
...a lot of html hererestart the clock.gif
Masai Lion
printF all the way .. I've send ya a dm about something else feel free to check it out .. happy debugging 🙂
Lionhead
chiming in here to say that my server this morning started responding to all requests (at least, to the homepage) with a 304. i would have left it running to debug but it was affecting users
could be this?