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 1 commit into from Feb 8, 2015


Copy link

@kanongil kanongil commented Jan 22, 2015

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.

@@ -202,6 +206,10 @@ internals.Connection.prototype._dispatch = function (options) {

return function (req, res) {

if (self._stopping) {
Copy link

@hueniverse hueniverse Jan 22, 2015

Why not just check _started?

Copy link
Contributor Author

@kanongil kanongil Jan 23, 2015

Because _started is always false when using inject().

Copy link

@hueniverse hueniverse Feb 9, 2015

Not if you also check for req.connection.

Copy link
Contributor Author

@kanongil kanongil commented Jan 23, 2015

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 and removed feature 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 issue Feb 8, 2015
Refuse to handle incoming request after server is stopped
@hueniverse hueniverse merged commit 1a71123 into hapijs:master Feb 8, 2015
1 check passed
hueniverse pushed a commit that referenced this issue Feb 9, 2015
@kanongil kanongil mentioned this pull request Feb 29, 2016
Copy link

@lock 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.
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants