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: don't create empty clientError listener for http.Server #1895

Merged
merged 1 commit into from Mar 23, 2022
Merged

fix: don't create empty clientError listener for http.Server #1895

merged 1 commit into from Mar 23, 2022

Conversation

nigelis
Copy link
Contributor

@nigelis nigelis commented Feb 17, 2022

Pre-Submission Checklist

Issues

Closes:

Changes

What does this PR do?

  • NOT create empty clientError listener for http.Server.

@nigelis nigelis changed the title Not proxy event listener for clientError NOT create empty clientError listener for http.Server Feb 17, 2022
Copy link
Contributor

@josephharrington josephharrington left a comment

Choose a reason for hiding this comment

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

Good find! Thanks @nigelis!

@josephharrington josephharrington changed the title NOT create empty clientError listener for http.Server fix: don't create empty clientError listener for http.Server Mar 23, 2022
@josephharrington josephharrington merged commit ddc1042 into restify:master Mar 23, 2022
josephharrington added a commit that referenced this pull request Mar 23, 2022
In the recent fix #1895, the `clientError` event was removed from the
list of events proxied from the underlying server object to the restify
Server. That fix was needed because merely adding a listener to the
underlying server for the `clientError` event prevents the default
behavior of returning an appropriate error code and closing the socket.
So by setting up a listener to proxy the event we were preventing that
default behavior, leading to hanging/leaked requests.

But! We should still support proxying `clientError` events if restify
users have added a listener for it. This enables logging or other custom
behavior. Restify users adding a `clientError` listener take on the
responsibility of sending an appropriate error and closing the socket,
exactly as noted in the Node.js docs for the `clientError` event.
https://nodejs.org/docs/latest-v16.x/api/http.html#event-clienterror

This change ensures we add a listener for `clientError` to the
underlying server object if and only if a listener for `clientError` has
been added to the restify server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants