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

fix(server): correctly handle errors on listen #1175

Merged
merged 1 commit into from
Dec 2, 2019

Conversation

targos
Copy link
Member

@targos targos commented Dec 2, 2019

The Promise constructor doesn't automatically catch errors if its handler
function is async. Use try/catch to avoid unhandled rejections.
If the server is closed because the port is already in used, use a
non-zero exit code and log it as an error.

… doesn't automatically catch errors if its handlerfunction is async. Use try/catch to avoid unhandled rejections.If the server is closed because the port is already in used, use anon-zero exit code and log it as an error.
@thetutlage
Copy link
Member

Is it mainly to handle the exceptions raised by the readyHooks?

@targos
Copy link
Member Author

targos commented Dec 2, 2019

@thetutlage yes

@targos
Copy link
Member Author

targos commented Dec 2, 2019

but the same reasoning can be used for the other lines, in case they result in a thrown error (for example if server.listen() gets wrong values as its port or host arguments)

@thetutlage thetutlage merged commit ebdf015 into adonisjs:develop Dec 2, 2019
@thetutlage
Copy link
Member

Thanks 👍

@targos targos deleted the fix-http-server branch December 2, 2019 13:14
@lock
Copy link

lock bot commented Mar 10, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants