Skip to content
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

next start without next build logs an error and leaves the request hanging #300

Closed
jamo opened this issue Nov 27, 2016 · 7 comments
Closed
Assignees

Comments

@jamo
Copy link
Contributor

jamo commented Nov 27, 2016

When next start is run without running next build prior to it, the server logs the error below while keeping the socket open eternally.
Curl eventually logs: curl: (52) Empty reply from server

{ Error: Cannot find module <snip>/next-test/.next/dist/pages/_error
    at _callee$ (/usr/local/lib/node_modules/next/dist/server/resolve.js:153:19)
    at tryCatch (/usr/local/lib/node_modules/next/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/next/node_modules/regenerator-runtime/runtime.js:337:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/next/node_modules/regenerator-runtime/runtime.js:96:21)
    at step (/usr/local/lib/node_modules/next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/lib/node_modules/next/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20 code: 'ENOENT' }
(node:31466) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: res.status is not a function
(node:31466) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce:

mkdir next-test
cd next-test
next init
npm install
npm run start

and then curl -v 127.0.0.1:3000

$ curl -v 127.0.0.1:3000
* Rebuilt URL to: 127.0.0.1:3000/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.50.3
> Accept: */*
>
* Curl_http_done: called premature == 0
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server
@jamo jamo changed the title next start without next build results next start without next build logs an error and leaves the request open Nov 27, 2016
@jamo jamo changed the title next start without next build logs an error and leaves the request open next start without next build logs an error and leaves the request hanging Nov 27, 2016
@arunoda
Copy link
Contributor

arunoda commented Nov 28, 2016

I think this is expected, you need to run next build before running next start.
Usually, you need to do next build while building the app and creating the runtime container (or similar)

Then you need to do next start.

Zeit's now runs npm run build inside it. For heroku you might need to do something like this.

@jamo
Copy link
Contributor Author

jamo commented Nov 28, 2016

I actually ran into this when "scripts.build": "next build" had a typo and the step was never run.

I mean, I wouldn't expect it to work, however, I wouldn't expect it fail like this (never responding anything).
Rather I would expect to have it returning a 500 error page.

@nkzawa
Copy link
Contributor

nkzawa commented Dec 1, 2016

I think we can check the existence of the .next directory and exit(1) if it's not there.

@rauchg
Copy link
Member

rauchg commented Dec 1, 2016

We definitely need to improve error handling here… Thanks @jamo

@rauchg
Copy link
Member

rauchg commented Dec 1, 2016

@nkzawa I would go further than that. We need to warn if you have a .next generated from development. Either that or we need to look for .next-prod ?

@nkzawa nkzawa added good first issue Easy to fix issues, good for newcomers and removed good first issue Easy to fix issues, good for newcomers labels Dec 29, 2016
@timneutkens
Copy link
Member

next start without a .next directory gives the following message in 2.0.0:

> Could not find the '.next' directory! Try building your app with 'next build' before starting the server.

@timneutkens
Copy link
Member

As @rauchg stated it does pass when it's a dev generated .next. I'll have a look into fixing that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants