Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Re-add support for clientError listeners
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.
- Loading branch information
1 parent
ddc1042
commit d5447f4
Showing
2 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters