-
Notifications
You must be signed in to change notification settings - Fork 42
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
emit res close event #138
emit res close event #138
Conversation
This commit updates the response logic to emit the 'close' event if the request is closed. Refs: hapijs/hapi#4208
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to do the trick but you could make it simpler, and avoid tracking the state, if you just condition the req.once('close', …)
on req._shot.simulate.close
.
Also, a test would be nice to ensure we don't regress.
I was hoping to detect any naturally occurring I'll look into adding a test. |
I am inclined to perform fixes on this with surgical precision to avoid any unexpected surprises. The implementation is quite brittle. |
It's a hard call for me. On one hand, this fix by Colin clearly enforces that when the request is closed that the response will follow, and there is value in ensuring that is always taken care of no matter the circumstance, since this is definitely what one can typically expect to observe with a real node http server. On the other hand, it is a little bit of a blunt instrument and doesn't a. give much intuition for why this is correct behavior or b. provide room for additional nuance or edge-cases if we find this isn't 100% correct. For example, I am not convinced that the My understanding is that what really happens in the node http server is that the underlying socket closing (a la
|
My point is to keep the fix simple, since it is a whole mess to untangle otherwise. This is further complicated by the fact that the exact node behavior can change between node releases. |
This commit updates the response logic to emit the 'close' event if the request is closed.
Refs: hapijs/hapi#4208
I tested these changes in hapi's master branch (combined with the change mentioned here) on Node 15.4.0, 15.5.1 (the currently broken release), 14.15.0, and 12.18.4. 🤷