-
Notifications
You must be signed in to change notification settings - Fork 804
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 socket from the request #1939
Conversation
|
I tested it manually and everything worked. I'll check what's wrong w/ the unit tests tomorrow. |
Awesome thanks for the contribution. Looks like a simple enough change and my guess is the test failures are because the mocks assumed the response is used but I'll hold off until tests are fixed. |
@dyladan I've fixed the tests, also added an integration test for this case. Please take another look. |
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.
lgtm
@mzahor FYI the PR need be rebased and its seems we can't do it ourselves from the github UI |
d1a2810
to
3cb569b
Compare
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
3cb569b
to
48cd0db
Compare
@vmarchaud Rebased. |
Fixes #1377
@blumamir and I investigated this issue and were able to reproduce it.
It happens if client uses the same TCP connection to send multiple requests (in keep-alive mode for example), so that there are multiple active requests on the same socket.
In this scenario, there is one socket for two request/response pairs and this socket is attached only to a single response on every given time.
So it may happen, that the instance of OutgoingMessage (response in our case), will not have a socket attached when handler calls the
response.end
function. In this case, the data will be pushed into an internal buffer https://github.com/nodejs/node/blob/75fd447/lib/_http_outgoing.js#L334.But in http plugin we try to access some properties of the socket, since it's equal to
null
we get anunhandledException
event and server crashes.Since the socket instance is the same for both request and response, it's enough to use
request.socket
to fix this issue and still have the same instrumentation data.This is a small tool that we used to simulate this scenario: