New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom build with App getInitialProps hangs #33615
Comments
I don't think we document this being a supported use case, but the issue seems to be that you have to exit the process yourself. const path = require("path")
const builder = require("next/dist/build").default
async function main() {
// Do some setup, then gather some config - such as from Gasket plugins
const config = {}
try {
await builder(path.resolve("."), config)
process.exit(0)
} catch (error) {
console.error(error)
process.exit(1)
}
}
main() should work. |
This shouldn't be closed yet. We shouldn't have to exit the process manually. My example repo has a contrived example, but with Gasket, we can perform other steps after the Next build has been completed. This has worked fine on previous versions of Next (8-11). Something introduced in Next 12 is causing this issue. |
And again, it only occurs with |
Unless we document What you could do instead is a script that only modifies the |
This fixes #33615. If an App uses `getInitialProps`, the build function never enters [this conditional block](https://github.com/vercel/next.js/blob/a52bd712fe797b59cfd05ceaa4c33096a0c346ff/packages/next/build/index.ts#L1481-L1484) and the static worker is left open.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.8
What version of Node.js are you using?
14.18.3
What browser are you using?
N/A
What operating system are you using?
macOS
How are you deploying your application?
next build
Describe the Bug
We have found a bug when using Next 12 with Gasket. When the custom
_app
usesgetInitialProps
, the process hangs and never finishes.This is reproducable with a very simple custom build script, such as in this repo.
When calling the Next
build
function from a script, the process hangs and never exits.Expected Behavior
Running a build by executing the
next/dist/build
function from a script completes and exits successfully.To Reproduce
Clone this repo, and run the custom build script.
The text was updated successfully, but these errors were encountered: