10 days ago
Hi folks! I'm debugging an issue where Railway deploys of a Next.js seem to be caching code from node_modules.
More concretely:
I apply a patch using
patch-packagetonode_modulesinpostinstalland alsoprebuild(just in case)I see the patch being applied in the log
However, the final build output in
.nextcontains old code
This is driving me nuts!
With some help from Claude, I've managed to narrow it down so that putting rm -rf .next/server .next/static .next/*.json .next/BUILD_ID || true in prebuild fixes the issue . I'll try to narrow it down further because I'm not sure which part helps.
But is there a documented list of all possible caches somewhere? I've tried adding NO_CACHE=1 to variables to no avail.
I'm not sure why I need to post project ID (aren't projects private) but mine is da45634a-bfa6-4338-9079-dc256ab1b66b/service/1abd16e0-ecab-4825-b3cf-262c4eaaa337 (I think?)
Thanks!
0 Replies
9 days ago
What builder are you using?
9 days ago
It looks like Railpack does in fact cache .next/cache.
9 days ago
And, as it happens, Nixpacks does too.
9 days ago
So, to answer your question about docs, the answer would be that it'll be in the documentation of whichever build system you're using.
I’m using the default one (Railpack). What I couldn’t find in the docs:
How to turn off this caching
What the exact cache keys are (I presume it’s fingerprinting the lockfile?)
Both of these are pretty critical to being able to resolve the issue. The “manually remove” approach I went with is a hack.
Also, usually deploying services have a “delete caches” and “redeploy without cache” button. So that’s a feature request I guess. I’m not sure how one is supposed to solve these types of issues otherwise.
9 days ago
The cache key should actually just be next. As far as turning it off, I'm not sure that's implemented at the moment, short of what you're doing right now.