We are running next.js(2.2.0) app in production for around a month. Sometimes, we get this error on server and page doesn't render.
` Error: Invalid Build File Hash(502475f53a0693f46b0bab538bdc8f4b) for chunk: app.js
at Server.handleBuildHash (node_modules/next/dist/server/index.js:1024:15)
at Server._callee7$ (node_modules/next/dist/server/index.js:337:28)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at F (node_modules/core-js/library/modules/_export.js:35:28)
at Object.<anonymous> (node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
at Object._nextHashAppJs [as fn] (node_modules/next/dist/server/index.js:351:26)`
Any idea what can be the cause?
Maybe a race condition? 馃 https://github.com/zeit/next.js/blob/master/server/index.js#L367
Got the same issue. Also this hook does not get called 馃槥
@albinekb it's not a race condition.
The hook is called when doing client side loading. (When there's a new deployment after page loads)
Basically what's happening is you are talking to two different builds which servers both .html file and the app.js files. That's the error.
Your routing system should have some sticky sessions like solution.
@arunoda could you show me where the hook is called? Was trying to debug but can't find it anywhere in the next code.
@seb0zz actually we changed the hook signature and we only updated the README.
Now I've updated the wiki as well: https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error
Thanks for pointing this out.
Thanks for updating!
@arunoda somehow this cannot be an issue with multiple servers behind a load balancer, half deployments or something else. I have an infrastructure with sticky load balancing, did not deploy anything for hours and still get the same issue as @skstronghold randomly but also very rarely.
This is the stacktrace:
Error: Invalid Build File Hash(48cf05711794d2de3f7826dab798442b) for chunk: app.js
at Server.handleBuildHash (/app/node_modules/next/dist/server/index.js:1028:15)
at Server._callee7$ (/app/node_modules/next/dist/server/index.js:332:28)
at tryCatch (/app/node_modules/regenerator-runtime/runtime.js:64:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/app/node_modules/regenerator-runtime/runtime.js:299:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/app/node_modules/regenerator-runtime/runtime.js:116:21)
at step (/app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /app/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at Promise.F (/app/node_modules/core-js/library/modules/_export.js:35:28)
at Object.<anonymous> (/app/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
at Object._nextHashAppJs [as fn] (/app/node_modules/next/dist/server/index.js:346:26)
at Router._callee$ (/app/node_modules/next/dist/server/router.js:87:62)
at tryCatch (/app/node_modules/regenerator-runtime/runtime.js:64:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/app/node_modules/regenerator-runtime/runtime.js:299:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/app/node_modules/regenerator-runtime/runtime.js:116:21)
at step (/app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /app/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at Promise.F (/app/node_modules/core-js/library/modules/_export.js:35:28)
at /app/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
at v (/app/node_modules/next/dist/server/router.js:98:31)
at Server._callee13$ (/app/node_modules/next/dist/server/index.js:551:24)
at tryCatch (/app/node_modules/regenerator-runtime/runtime.js:64:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/app/node_modules/regenerator-runtime/runtime.js:299:22)
@arunoda I'm getting this error again even after I updated the file just like you said:

@ilionic some of next.js problems never resolve. clearly this issue shouldn't be closed.
I analysed IP鈥檚 and turned out those were coming from bots, that most likely hold some internal caches. Real users are most likely not impacted as far as I can see.
@ilionic I am impacted and as far as i can check, i'm not a bot.
We are running 2 pods after a load balancer where traffic is divided over these 2 pods (similar to docker container).
In 1 pod we get:
08:26:05 0|server | Error: Invalid Build File Hash(fc1c721bd46da1cb8f478719791ade97) for chunk: app.js
08:26:05 0|server | at Server.handleBuildHash (/nodejs/node_modules/next/dist/server/index.js:1265:15)
08:26:05 0|server | at Server._callee9$ (/nodejs/node_modules/next/dist/server/index.js:486:28)
08:26:05 0|server | at tryCatch (/nodejs/node_modules/regenerator-runtime/runtime.js:62:40)
08:26:05 0|server | at Generator.invoke [as _invoke] (/nodejs/node_modules/regenerator-runtime/runtime.js:296:22)
08:26:05 0|server | at Generator.prototype.(anonymous function) [as next] (/nodejs/node_modules/regenerator-runtime/runtime.js:114:21)
08:26:05 0|server | at step (/nodejs/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
08:26:05 0|server | at /nodejs/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
08:26:05 0|server | at new Promise (<anonymous>)
08:26:05 0|server | at new F (/nodejs/node_modules/core-js/library/modules/_export.js:35:28)
08:26:05 0|server | at Object.<anonymous> (/nodejs/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
Cleary this shouldn't be just closed, but fixed.
You are right, @neanex. ~90% of occurrences were coming from bots but 10% real users.. No clues so far.
Most helpful comment
@seb0zz actually we changed the hook signature and we only updated the README.
Now I've updated the wiki as well: https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error
Thanks for pointing this out.