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
Handle buffers directly instead of using "bl" #2424
Conversation
If i recall, the original thinking was "maybe we can eventually just pass the bl instance to the callback" instead of doing the concatenation and underlying memcopy of the buffers. Turns out it's just too difficult to "pretend" to be a Buffer reliably and integrate with instanceof checks and |
To be clear, I'm +1 on the premise, but I haven't had the time to code review quite yet. |
Thank you, I appreciate the background. For context, this is just one of many more upcoming PRs. My end goal is to improve |
I wonder why the code coverage went down, this still hit a bunch of our existing tests :( |
This could be improved by keeping a running total that's passed as the second argument to |
I've updated the PR by rebasing onto master and adding the length tracking as suggested by @mscdex |
@@ -1021,22 +1022,20 @@ Request.prototype.readResponseBody = function (response) { | |||
debug('aborted', self.uri.href) | |||
// `buffer` is defined in the parent scope and used in a closure it exists for the life of the request. | |||
// This can lead to leaky behavior if the user retains a reference to the request object. | |||
buffer.destroy() | |||
buffers = [] |
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.
Minor nit: perhaps to be consistent with the changes down below, bufferLength = 0
should be added after this line as well?
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.
done!
LGTM and CI is green :-) |
bl
does a lot, butrequest
's needs are pretty simple. This PR removesbl
in favor of operating on buffers directly. There is no change in functionality here -bl
also callsBuffer.concat
when slicing an all bufferBufferList
.