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

Refuse to handle incoming request after server is stopped #2363

Merged
merged 1 commit into from Feb 8, 2015

Conversation

kanongil
Copy link
Contributor

As described in nodejs/node-v0.x-archive#9066, node can continue to emit request events on closed http servers. This patch works around this by checking if the server is stopping before responding to incoming requests.

@kanongil kanongil added the feature New functionality or improvement label Jan 22, 2015
@@ -202,6 +206,10 @@ internals.Connection.prototype._dispatch = function (options) {

return function (req, res) {

if (self._stopping) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just check _started?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because _started is always false when using inject().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if you also check for req.connection.

@kanongil
Copy link
Contributor Author

I'm sure there are other ways to fix this, but this seemed quite simple. Another approach could be to remove the request listener when close is called. However, we would not be able to end() the underlying connection before the timeout, which I'm not entirely certain is a good idea anyway, as it will probably abort pending pipelined responses.

@hueniverse hueniverse added bug Bug or defect and removed feature New functionality or improvement labels Feb 8, 2015
@hueniverse hueniverse self-assigned this Feb 8, 2015
@hueniverse hueniverse added this to the 8.2.0 milestone Feb 8, 2015
hueniverse pushed a commit that referenced this pull request Feb 8, 2015
Refuse to handle incoming request after server is stopped
@hueniverse hueniverse merged commit 1a71123 into hapijs:master Feb 8, 2015
hueniverse pushed a commit that referenced this pull request Feb 9, 2015
@kanongil kanongil mentioned this pull request Feb 29, 2016
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants