Uh oh!
There was an error while loading. Please reload this page.
Include listen errors in app.listen() callback - #2623
Conversation
dougwilson
commented
Apr 19, 2015
You can call This is also pretty breaking, because no one has been adding |
dougwilson
commented
Apr 19, 2015
Also, if you were just adding this for the listening error, the app.listen(3000,function(err){// ... do stuff}) |
wesleytodd
commented
Apr 19, 2015
@dougwilson Ok, thats cool, it was just a one line change so I figured I would do it and see your thoughts. Your points make perfect sense, I guess I have just never used multiple listens (I use nginx for ssl term). For the callback scenario, maybe I am doing something wrong, but the process.on('uncaughtException',function(err){console.error('Uncaught: ',err);});app.listen(app.get('port'),app.get('hostname'),function(err){if(err){returnconsole.error('Error starting server',err);}console.log('Listeneing');});And the output is: This situation is the only reason I thought this might be a nicer api, since the best one is apparently not working correctly now. |
dougwilson
commented
Apr 19, 2015
Oops, I was not remembering correctly. The |
wesleytodd
commented
Apr 19, 2015
Ignoring the fact that i didn't change the tests, what do you think of this: wesleytodd@a8bc849 Also ignore the tabs, I would fix those up before submitting. :) |
dougwilson
commented
Apr 19, 2015
In general, looks fine. I would skip manipulating the |
wesleytodd
commented
Apr 19, 2015
Ok, hows that? |
There was a problem hiding this comment.
Should probably use the same context as the listening event does: against ee instead of app.
wesleytodd
commented
Apr 19, 2015
Let me know if you want me to change anything else!! |
dougwilson
commented
Apr 19, 2015
Thanks, @wesleytodd , looks fine and targeted for 4.13 :) |
There was a problem hiding this comment.
Can this port number be made dynamic? Getting some race conditions where the Express suite is running multiples times on the same machine and they all want to use port 9999. Just have app listen randomly and have app2 listen to whatever port app is listening on should work.
There was a problem hiding this comment.
Yeah, I can make this change for sure. Let me know if you also want me to move this PR to the 5.0 branch and I will do it all at once.
dougwilson
commented
Jun 19, 2015
Ok, cool, I got your changes all fixed up :) I found while testing that there are some issues with adding this in 4.x, namely that people are unconditionally assuming the callback means the server is up. I definitely love this convenience and will have it land in 5.0 instead \m/ |
wesleytodd
commented
Jun 19, 2015
Sounds good!! let me know if there is anything else you need from me, but it looks like it is all good! |
5f268a4 to
9848645Comparewesleytodd
commented
Feb 20, 2016
If this is slated for 5, should I re-make this PR against the 5.0 branch? Or are you pulling in the change manually? If so I can close this out. |
wesleytodd
commented
Feb 20, 2017
Closed in favor of #3216 |
I know that you can listen on the server instance, but it seems like this might be nicer to just proxy up the error event. Thoughts?