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: use more reliable close event #1880

Merged
merged 3 commits into from
Sep 29, 2021
Merged

Conversation

mmarchini
Copy link
Contributor

The close event from the request object is not guaranteed to fire on the
same order across major versions of Node.js, the more accurate way to
look if the connection was closed is to listen to the event on the
socket. Fixes tests on v16.

Ref: nodejs/node#38924

The close event from the request object is not guaranteed to fire on the
same order across major versions of Node.js, the more accurate way to
look if the connection was closed is to listen to the event on the
socket. Fixes tests on v16.

Ref: nodejs/node#38924
@mmarchini mmarchini merged commit 71c7f49 into restify:master Sep 29, 2021
@mmarchini mmarchini deleted the nodejs-16 branch September 29, 2021 03:59
josephharrington added a commit that referenced this pull request Jan 31, 2022
In #1880, we switched from using the close event on `req` to close on
`req.socket`. This addressed the intended issue but can trigger frequent
warnings when keep-alive is used due to a listener being added for each
request on the same socket.

By using the close event on `res` instead, we address both the issue of
event ordering in Node.js >= 16 that the original change was targeting
and the event emitter warning leak.
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.

1 participant