You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
If a user happens to request an old bundle resource with an old hash, the response should 404, not 500.
Current Behavior
I'm currently running a Next.js app at https://www.tenable.com/plugins and I'm getting quite a few 500 errors in my logs after I deploy a new version that has a new hash from the build (I'm using sticky sessions to minimize the disruption, but still see some errors long after the deploy).
Well actually the status code is a 200. It would be great if it would return a non successful status code. I use Cloudflare to cache all my static assets and right now it caches the '500' one because it thinks it's a 200. I assume these assets are all unique due to their ID so I cache them for a month which has a big chance of breaking my site during rolling deployments.
Think this tweak to handleBuildHash would take care of setting the status correctly in production when the hash doesn't match? Would it be okay if I opened a PR with this?
handleBuildHash(filename,hash,res){if(this.dev){res.setHeader('Cache-Control','no-store, must-revalidate')returntrue}if(hash!==this.buildStats[filename].hash){if(this.dev){thrownewError(`Invalid Build File Hash(${hash}) for chunk: ${filename}`)}this.send404(res);}res.setHeader('Cache-Control','max-age=31536000, immutable')returntrue}
timteeling
added a commit
to timteeling/next.js
that referenced
this issue
Mar 5, 2018
Expected Behavior
If a user happens to request an old bundle resource with an old hash, the response should 404, not 500.
Current Behavior
I'm currently running a Next.js app at https://www.tenable.com/plugins and I'm getting quite a few 500 errors in my logs after I deploy a new version that has a new hash from the build (I'm using sticky sessions to minimize the disruption, but still see some errors long after the deploy).
Steps to Reproduce (for bugs)
200 -> https://custom-server-koa-wxksegmzhf.now.sh/_next/7c048a193f99703d6180e88866b6e06b/app.js
500 Internal server error -> https://custom-server-koa-wxksegmzhf.now.sh/_next/OLD_HASH_VALUE/app.js
Source code area of interest: https://github.com/zeit/next.js/blob/1aade36f13e03db13d23f86dc52a459f9a29e03d/server/index.js#L467
Context
Just trying to minimize the number of unneeded 500 errors 😄
Appreciate all your work and effort!
Your Environment
The text was updated successfully, but these errors were encountered: