Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

krydos
Copy link
Contributor

@krydos krydos commented May 2, 2017

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.

_stream_wrap.js:42
  this.stream.pause();
              ^

TypeError: this.stream.pause is not a function
    at new StreamWrap (_stream_wrap.js:42:15)
    at new TLSSocket (_tls_wrap.js:280:12)
    at Object.<anonymous> (/path/to/test-file.js:4:1)
    at Module._compile (module.js:582:30)
    at Object.Module._extensions..js (module.js:593:10)
    at Module.load (module.js:516:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:618:10)
    at startup (bootstrap_node.js:144:16)
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

@nodejs-github-bot nodejs-github-bot added the tls Issues and PRs related to the tls subsystem. label May 2, 2017
@mscdex
Copy link
Contributor

mscdex commented May 2, 2017

Can you include a test that fails without this change?

@krydos
Copy link
Contributor Author

krydos commented May 3, 2017

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.

@mscdex
Copy link
Contributor

mscdex commented May 3, 2017

/cc @nodejs/crypto

Copy link
Member

@addaleax addaleax left a 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.

@addaleax
Copy link
Member

addaleax commented May 3, 2017

Also, can you edit the commit message to add a Fixes: https://github.com/nodejs/node/issues/3655 line? :)

@krydos
Copy link
Contributor Author

krydos commented May 3, 2017

@addaleax I've update commit message, thank you. And actually thank you for helping me to understand and fix the issue :)

@addaleax addaleax added the semver-major PRs that contain breaking changes and should be released in the next major version. label May 4, 2017
@addaleax
Copy link
Member

addaleax commented May 4, 2017

Labelled semver-major to be on the safe side

CI: https://ci.nodejs.org/job/node-test-commit/9635/

@krydos
Copy link
Contributor Author

krydos commented May 5, 2017

I think CI hates me 😢

Could you please approve I understand CI output correctly, and it is not related?

@lpinca
Copy link
Member

lpinca commented May 5, 2017

@krydos gonna start a new one.

CI 2: https://ci.nodejs.org/job/node-test-pull-request/7880/

cjihrig
cjihrig previously requested changes May 9, 2017
const EventEmitter = require('events').EventEmitter;
assert.throws(
() => { new TlsSocket(new EventEmitter()); },
/^TypeError:/
Copy link
Contributor

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.

Copy link
Member

@indutny indutny left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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...

@krydos
Copy link
Contributor Author

krydos commented May 10, 2017

@cjihrig I've added full error message to the test.
@indutny unnecessary parantecies are removed.

Thank you for the feedback!

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)
Copy link
Member

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

Copy link
Contributor Author

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 :)

@addaleax
Copy link
Member

Landed in b23d414

@addaleax addaleax closed this May 15, 2017
addaleax pushed a commit that referenced this pull request May 15, 2017
Fixes: #3655
PR-URL: #12799
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
@krydos krydos deleted the issue-3655 branch May 15, 2017 18:02
@addaleax addaleax removed the semver-major PRs that contain breaking changes and should be released in the next major version. label May 15, 2017
@addaleax
Copy link
Member

Looking back, I don’t think labelling this semver-major is necessary – I’d prefer to wait a bit before backporting, though.

@krydos
Copy link
Contributor Author

krydos commented May 15, 2017

@addaleax agree with you. Looks more as a bugfix. I hope there are no users of Node.js who rely on this error.

@gibfahn
Copy link
Member

gibfahn commented May 18, 2017

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/

@addaleax
Copy link
Member

@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. :)

anchnk pushed a commit to anchnk/node that referenced this pull request May 19, 2017
Fixes: nodejs#3655
PR-URL: nodejs#12799
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
@jasnell jasnell mentioned this pull request May 28, 2017
@gibfahn gibfahn mentioned this pull request Jun 15, 2017
3 tasks
@MylesBorins MylesBorins added baking-for-lts PRs that need to wait before landing in a LTS release. lts-watch-v6.x labels Jun 22, 2017
@MylesBorins
Copy link
Contributor

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

@MylesBorins MylesBorins removed the baking-for-lts PRs that need to wait before landing in a LTS release. label Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants