I've upgraded to Next.js 8 and noticed my next build (which is triggered by yarn build) leaves process hanging forever and doesn't exit it. So, my CI is timing out and we can't push the upgrade to production yet.
Simply running next build. Here's my current next.config.js:
const webpack = require('webpack')
const path = require('path')
const package = require('./package.json')
const DotenvPlugin = require('dotenv-webpack')
const withProgressBar = require('next-progressbar')
const withOffline = require('next-offline')
const withCSS = require('@zeit/next-css')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = withOffline(withCSS(withProgressBar({
progressBar: {
profile: true,
},
workboxOpts: {
runtimeCaching: [
{
urlPattern: /^https?.*/,
handler: 'networkFirst',
options: {
cacheName: 'name-v' + package.version,
expiration: {
maxEntries: 50,
maxAgeSeconds: 7 * 24 * 60 * 60,
purgeOnQuotaError: true,
},
},
},
],
},
webpack: (config, { isServer }) => {
config.plugins.push(new DotenvPlugin({
systemvars: isProduction,
}))
if (!isServer) {
config.module.rules.unshift({
test: /\.worker\.js$/,
use: [{
loader: 'worker-loader',
options: {
inline: true,
},
}],
})
}
/**
* Hotfix for new webpack hot reload bug
*/
if (!isServer) {
config.output.globalObject = 'self'
}
return config
},
})))
Process should exit after compilation is successful.

Not many changes, I simply upgraded Next from v7 to v8. It also seems to have no warnings of peer dependencies compatibility issues. Everything else is running fine. If I ctrl+C the build process and run yarn start, everything is working just fine. Development server is working perfectly as well.
I found similar issues (https://github.com/zeit/next.js/issues/7567, https://github.com/zeit/next.js/issues/4647, https://github.com/zeit/next.js/issues/6419) suggesting to install next-progressbar, removing node_modules, yarn.lock, package-lock.json, .next directory etc. I did all of that but absolutely nothing changed this outcome.
Any thoughts? Thanks 馃槄
Can you please try next@canary? I assume one of your pages is establishing a connection or similar and never allows the process to exit.
Can you please try
next@canary? I assume one of your pages is establishing a connection or similar and never allows the process to exit.
Works (^8.1.1-canary.57)!

+1
Closing this because you said it works @gugiserman!
Updating to canary also fixed for me.
Same issue I am facing with firebase. Help me
Upgrading Next.js to latest version solved my issue
NOTE: kindly avoid [email protected]. (Build bundling stuck for forever and not exiting).
Most helpful comment
Can you please try
next@canary? I assume one of your pages is establishing a connection or similar and never allows the process to exit.