-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
tls: do not wrap net.Socket with StreamWrap #12799
Conversation
Can you include a test that fails without this change? |
test added. Thank you @mscdex . test expect TypeError and do not check the exact error message. I did it like that mostly because test should check the fact that exception was thrown. |
/cc @nodejs/crypto |
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.
Looks good to me, but to be careful we should maybe consider this semver-major (@nodejs/ctc), and it would be good to have @indutny give this a look if possible.
Also, can you edit the commit message to add a |
@addaleax I've update commit message, thank you. And actually thank you for helping me to understand and fix the issue :) |
Labelled |
I think CI hates me 😢 Could you please approve I understand CI output correctly, and it is not related? |
@krydos gonna start a new one. CI 2: https://ci.nodejs.org/job/node-test-pull-request/7880/ |
const EventEmitter = require('events').EventEmitter; | ||
assert.throws( | ||
() => { new TlsSocket(new EventEmitter()); }, | ||
/^TypeError:/ |
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.
I know you commented on this already, but please check the full error message.
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
lib/_tls_wrap.js
Outdated
else if ((socket instanceof net.Socket) && !socket._handle) | ||
wrap = new StreamWrap(socket); | ||
else | ||
if (((socket instanceof net.Socket) && socket._handle) || !socket) |
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, lots of unnecessary parens. Do we allow them with lint?
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.
linter was quiet in this case. I'm also wasn't able to find rule to check this...
lib/_tls_wrap.js
Outdated
else if ((socket instanceof net.Socket) && !socket._handle) | ||
wrap = new StreamWrap(socket); | ||
else | ||
if (socket instanceof net.Socket && socket._handle || !socket) |
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.
I think @indutny was just talking about the inner parentheses – I would really prefer to keep the ones around the &&
expression for readability
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.
@addaleax oops, didn't understand it correctly. Sorry.
I've added parentheses around && expression. Thank you :)
Landed in b23d414 |
Fixes: #3655 PR-URL: #12799 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
Looking back, I don’t think labelling this semver-major is necessary – I’d prefer to wait a bit before backporting, though. |
@addaleax agree with you. Looks more as a bugfix. I hope there are no users of Node.js who rely on this error. |
CitGM run: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/796/ |
@gibfahn The “error” in this case is a failed C++ assertion (i.e. hard crash), just in case you were thinking this is about error messages. :) |
Fixes: nodejs#3655 PR-URL: nodejs#12799 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
I've thrown a baking for lts label on this PR... if the PR shouldn't land on v6.x please remove and add don't land label |
Hi :)
In this PR I just wanted to avoid "c-like" error from this issue - #3655. You can see below how error looks like now. At least there is stacktrace exist.
Please update me if I did something horribly wrong here or maybe if this is not a fix at all so I will close this PR.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)