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

More informative error if expected port is not available for ember serve #1306

Closed
awildeep opened this issue Jul 7, 2014 · 8 comments
Closed
Labels

Comments

@awildeep
Copy link

awildeep commented Jul 7, 2014

This is a wish list item, and more for making user experience more pleasant.

I saw someone run into this during their recorded talk at Wicked Good Ember, and I have hit this myself. It usually costs me a few minutes of time before I figure out why it fails, but when I do I always wish the error reported back was more intelligent.

To recreate:

  1. Open a terminal, and go to an existing ember-cli application
  2. Run ember serve
  3. Open a new terminal, and go to an existing ember-cli application leaving the first open
  4. Run ember serve and receive the cryptic message as follows:
version: 0.0.39

... Uhoh. Got error listen EADDRINUSE ...
Error: listen EADDRINUSE
  at errnoException (net.js:904:11)
  at Server._listen2 (net.js:1042:14)
  at listen (net.js:1064:10)
  at Server.listen (net.js:1138:5)
  at Server.listen (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/tiny-lr/lib/server.js:138:15)
  at resolver (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/node.js:183:26)
  at initializePromise (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/-internal.js:202:9)
  at new Promise (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:149:9)
  at /Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/node.js:152:20
  at tryCatch (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/-internal.js:163:16)
  at invokeCallback (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/-internal.js:172:17)
  at /Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:186:17
  at flush (/Users/gsm/Repositories/ember/my-auth-app/node_modules/ember-cli/node_modules/rsvp/dist/commonjs/rsvp/asap.js:51:9)
  at process._tickCallback (node.js:419:13)


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE
  at errnoException (net.js:904:11)
  at Server._listen2 (net.js:1042:14)
  at listen (net.js:1064:10)
  at net.js:1146:9
  at dns.js:72:18
  at process._tickCallback (node.js:419:13)

Of course after knowing that this problem exists (obviously I can't run two servers on the same port), the error string '... Uhoh. Got error listen EADDRINUSE ...' seems very undescriptive. Perhaps it would be useful to tell the user that the port/address they requested to run the server as is unavailable. And give them some possible solutions such as stopping other ember serve processes, or changing the port using the ---port toggle.

Again, this is a low priority, but a quality of life improvement as I see it.

@rwjblue
Copy link
Member

rwjblue commented Jul 7, 2014

I think that we can handle this via configstore, which we already include and use. Basically, we could increment a port number count or something and just handle this properly.

We could also trap the EADDRINUSE error, and print a canned response letting the use know that the part/address was already in use (which is what EADDRINUSE means).

@awildeep
Copy link
Author

awildeep commented Jul 7, 2014

@rjackson I'd be happy with the second solution. I could see some potential issues with auto incrementing the port number, for example:

  • What if ports 4200-4299 are in use? Do you increment until 4300?
  • What if a user does this on an already specified port, would it increment? I think an error makes more sense here especially.

If my experience in software has taught me anything, giving users quality information on error is infinitely more valuable than a canned constant.

@stefanpenner
Copy link
Contributor

I don't think incrementing is correct, rather we should provide "what port" we are trying to bind to in the error message, people can then resolve the issue themselves.

I can't believe the default error doesn't just provide this info.

@awildeep
Copy link
Author

awildeep commented Jul 7, 2014

To me EADDRINUSE is cryptic. Non-native english speakers (not to mention a bunch of native English speakers) will find this hard to understand compare to an error message like:

Unable to start the server at http://0.0.0.0:4200 as it is in use or you do not have permission. 
    Suggestion: try setting the port with the --port option.
        Example: ember serve --port 4201

I am posting this copy as an example of what I consider a good error message, it tells the user:

  1. Something went wrong, or at least not as expected.
  2. What was tried, and a bit of context to show them why.
  3. A potential solution to their issue that does not involve open https://www.google.com/#q=emberjs+EADDRINUSE

@stefanpenner
Copy link
Contributor

@awildeep yes, I agree. Annoyingly this error is from node, we will have to catch check and rethrow a new one to improve this issue. This is worth it, although I wont have time anytime soon.

@stefanpenner
Copy link
Contributor

i believe @gavacho & friends are looking into this.

@kimroen
Copy link
Contributor

kimroen commented Jul 8, 2014

Merged: #1309

@rwjblue rwjblue closed this as completed Jul 8, 2014
@awildeep
Copy link
Author

awildeep commented Jul 8, 2014

That was a quick patch. Thanks @gavacho & friends!

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

No branches or pull requests

4 participants