Skip to content

async_wrap: add asyncReset to TLSWrap - #13092

Merged
refack merged 0 commit into
nodejs:masterfrom
refack:async-wrap-13045
May 20, 2017
Merged

async_wrap: add asyncReset to TLSWrap#13092
refack merged 0 commit into
nodejs:masterfrom
refack:async-wrap-13045

Conversation

@refack

@refackrefack commented May 18, 2017

Copy link
Copy Markdown
Contributor

When using an Agent for HTTPS, TLSSockets are reused and need to
have the ability to asyncReset from JS.

Fixes: #13045
(Not a complete solution. Does not solve custom Agent use case)

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)

async_wrap

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. tls Issues and PRs related to the tls subsystem. labels May 18, 2017
@refackrefack self-assigned this May 18, 2017
@refack

Copy link
Copy Markdown
ContributorAuthor

CI: https://ci.nodejs.org/job/node-test-commit/9967/
(just cause my computer takes so long to build...)

@mscdexmscdex added the wip Issues and PRs that are still a work in progress. label May 18, 2017
@refack
refackforce-pushed the async-wrap-13045 branch from 077f403 to dcdc104CompareMay 18, 2017 10:13
@refackrefack changed the title [WIP] test-balloon: investigate #13045async_wrap: add asyncReset to TLSWrapMay 18, 2017
@refackrefack removed the wip Issues and PRs that are still a work in progress. label May 18, 2017
@refack

Copy link
Copy Markdown
ContributorAuthor

@refack
refack requested a review from trevnorrisMay 18, 2017 10:18
@refack

Copy link
Copy Markdown
ContributorAuthor

@AndreasMadsenAndreasMadsenMay 18, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to add this listener? If there is an error in the future I think it would be better to see that error than an AssertionError('must not throw') message.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 and put assert.ifError?
Ok.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will just throw by default, which will cause the test to fail.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you don't get which line... And since there are two almost identical calls it's a PITA (just been there while writing this test)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I think the ifError approach is fine then.

@refack

Copy link
Copy Markdown
ContributorAuthor

@AndreasMadsenAndreasMadsen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cjihrigcjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of nits with the test, but mostly LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks for the issue in -> Refs:

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace the uses of assert.ifError() with common.mustNotCall(). You can provide a custom message with the latter if you'd like.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #13092 (comment)
@AndreasMadsen suggested that we might want to see the actual error.
(Maybe we need mustNotErr like assert.doesNotThrow)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, you might want to use assert.fail() instead. ifError() implies that there might not be an error, but in this case, we know that there is one.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a factory method mustNotErr that calls assert.fail so the fail point will appear in the stack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a sense yes, I just wanted to be explicit about the pain point.
I could replace this with a comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you drop the try...catch completely, and if it happens to throw, it will fail the test.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Replaced with a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if my previous comment was unclear. I just meant to write this as:

Refs: #13045

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you need this. You can just pass assert.fail (without the parens) as the handler, everywhere you use mustNotErr().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it, then there is no frame for the line with the failing assert (Actually the factory is not a solution I need explicit (err) => assert.fail(err))

Generated error by setting port: port + 1
with (err) => assert.fail(err)

assert.js:92thrownewAssertionError({^AssertionError[ERR_ASSERTION]: Error: writeEPROTO101057795:error:140770FC:SSLroutines:SSL23_GET_SERVER_HELLO:unknownprotocol:openssl\ssl\s23_clnt.c:794:
atClientRequest.req.on(D:\code\node-cur\test\parallel\test-async-wrap-GH13045.js:63:35)atemitOne(events.js:115:13)atClientRequest.emit(events.js:210:7)atTLSSocket.socketErrorListener(_http_client.js:397:9)atemitOne(events.js:115:13)atTLSSocket.emit(events.js:210:7)atonwriteError(_stream_writable.js:359:10)atonwrite(_stream_writable.js:377:5)atfireErrorCallbacks(net.js:522:13)atTLSSocket.Socket._destroy(net.js:563:3)

with just assert.fail

assert.js:92thrownewAssertionError({^AssertionError[ERR_ASSERTION]: Error: writeEPROTO101057795:error:140770FC:SSLroutines:SSL23_GET_SERVER_HELLO:unknownprotocol:openssl\ssl\s23_clnt.c:794:
atemitOne(events.js:115:13)atClientRequest.emit(events.js:210:7)atTLSSocket.socketErrorListener(_http_client.js:397:9)atemitOne(events.js:115:13)atTLSSocket.emit(events.js:210:7)atonwriteError(_stream_writable.js:359:10)atonwrite(_stream_writable.js:377:5)atfireErrorCallbacks(net.js:522:13)atTLSSocket.Socket._destroy(net.js:563:3)atWriteWrap.afterWrite[asoncomplete](net.js:857:10)

@Fishrock123

Fishrock123 commented May 18, 2017

Copy link
Copy Markdown
Contributor

Sounds correct to me.

@mcollina

Copy link
Copy Markdown
Member

Can we get a CITGM run? that has been the main blocker for me.

@addaleax

Copy link
Copy Markdown
Member

@mscdexmscdexMay 18, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this more or less equivalent to just not adding an 'error' listener? Similarly with the 'error' handlers above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I'm -0 on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the response handler as a second argument here for consistency?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto about switching to https.get().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, ack.

@mscdexmscdexMay 18, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.mustCall((req, res) => { ... }, 2) ?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these last two options necessary?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just last one: AssertionError [ERR_ASSERTION]: Error: self signed certificate in certificate chain

@mscdexmscdexMay 18, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think method: 'GET' could be dropped and .request() changed to .get() to avoid the need to req.end().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed, it's even the default.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@refack

Copy link
Copy Markdown
ContributorAuthor

@refack

refack commented May 19, 2017

Copy link
Copy Markdown
ContributorAuthor

Pre land CI:https://ci.nodejs.org/job/node-test-commit/10006/

Ping @trevnorris any comments? I would like to land this in a few hours.

@refack
refackforce-pushed the async-wrap-13045 branch from ce6215e to 834e4cdCompareMay 19, 2017 16:22
@refackrefack closed this May 20, 2017
@refack
refackforce-pushed the async-wrap-13045 branch from 834e4cd to 6bfdeedCompareMay 20, 2017 03:28
@refack

Copy link
Copy Markdown
ContributorAuthor

Landed in 6bfdeed

@refack
refack merged commit 6bfdeed into nodejs:masterMay 20, 2017
@refack

Copy link
Copy Markdown
ContributorAuthor

@refack
refack deleted the async-wrap-13045 branch May 20, 2017 03:33
@AndreasMadsen

Copy link
Copy Markdown
Member

@refack Thanks for taking care of this.

@mcollina

Copy link
Copy Markdown
Member

Thank you @refack. 🎉

@MylesBorins

Copy link
Copy Markdown
Contributor

This should likely be included in a larger async_wrap backport if it were to happen

@MylesBorinsMylesBorins added the baking-for-lts PRs that need to wait before landing in a LTS release. label Aug 14, 2017
@MylesBorinsMylesBorins removed the baking-for-lts PRs that need to wait before landing in a LTS release. label Aug 17, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.tlsIssues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-npm failing on master after introduction of initial async hooks implementation

9 participants

@refack@Fishrock123@mcollina@addaleax@AndreasMadsen@MylesBorins@mscdex@cjihrig@nodejs-github-bot