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
THRIFT-5710: Stop sharing headers across all instances of transports in nodejs #2805
Conversation
15de6e1
to
27f369d
Compare
transport.inBuf = buf; | ||
|
||
const headers = transport.readHeaders(); | ||
assert.equals(headers.Parent, undefined); |
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.
Just to be 100% clear, before this fix, headers
would have contained { Parent: "shoobar", Parens: "shoobaz", Trace: "abcde" }
because it was reusing the same object as the first test. This is not test-only though and happens in real life.
Similar story for the write test.
@Jens-G I'm going to assume that the cross-test failures are not from me since none of them involve nodejs. Safe to assume? |
Yes, seems so. |
Sounds good. Thoughts on the bug and the PR? We're blocked on using nodejs Thrift on this, so I'm eager to get this one in. |
@Jens-G Anything you need from me to review this? Happy to do whatever it takes! |
Thanks @Jens-G! Can we cut a new npm package as well? |
Sure, after release (somewhere this summer) as usual there will be a new npm package. |
THRIFT-5710
There is an issue with the header transport implementation in
nodejs
. All TBufferedTransport and TFramedTransport instances across all connections and clients share a single object for their read and write headers. There is a different copy for the two transport types, but within one type, they are shared.This means that there are both data races and incorrect results possible:
getReadHeaders
.The issue is that we aren't calling the header transport constructor with the new
this
from the concrete implementations, so theTBufferedTransport.prototype = new THeaderTransport();
line is not properly bindingthis
and causes the object sharing.You can see this in the two test cases that fail before this PR and succeed now. Two completely unrelated
TFramedTransport
objects shared read and write results.I did not create a JIRA ticket yet because I am still waiting on approval, but I wanted to get the PR up ASAP; we are currently experiencing this bug in production.
Note: my editor reformatted those two or three random lines because they had trailing whitespace and/or tabs, which is against the coding style. I can revert them if you want this PR to be clean, but figured I'd leave the changes in since the existing files were incorrectly formatted.
[skip ci]
anywhere in the commit message to free up build resources.