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
Double server from CLI #38232
Comments
Also have this issue when deploying on AWS Beanstalk |
I don't think the server is started twice: The first log is coming from next.js/packages/next/cli/next-start.ts Line 88 in 6b8e499
and the second one is from
|
|
I searched a bit and the issue first appeared in version 12.1.1-canary.5. Importing edit: When This 2nd edit: |
#38274) Fixes: #38232 Fixes: #36893 Version [12.1.1-canary.5](https://github.com/vercel/next.js/releases/tag/v12.1.1-canary.5) introduced a bug, more specifically this PR: #34836 The issue described in #38232 is that the following code starts both the dev and prod servers: ```js const start = require('next/dist/cli/next-start') start.nextStart() ``` I searched a bit and found that `lib/get-project-dir.ts#getProjectDir()` now imports `bin/next.ts` https://github.com/vercel/next.js/blob/6b8e499c7bf13914cca92f9da1737d358133ee20/packages/next/lib/get-project-dir.ts#L3 and it calls a CLI command via https://github.com/vercel/next.js/blob/6b8e499c7bf13914cca92f9da1737d358133ee20/packages/next/bin/next.ts#L137 This `command` should not be defined, but it fallbacks to `defaultCommand`, which is `dev` (that explains why the dev server is also started) This PR moves the `cliCommand` types and `commands` variable to a new separate file instead of `bin/next.ts`, to avoid running a CLI command when we import any file that also imports `lib/get-project-dir.ts` Not sure how integration tests can be added for this issue, but feel free to tell me. Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
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. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
CLI
Describe the Bug
I have
app.js
file in root folder.It starts 2 servers at the same time. It starts dev server instead of production and overwrites contents of
.next
folder with files of dev server.Accessing localhost:3000 returns error 404
Expected Behavior
Only start production server
Link to reproduction
https://github.com/Arctomachine/reproduction-double-server
To Reproduce
next build
node app.js
The text was updated successfully, but these errors were encountered: