-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
http: set async_id_symbol to any socket set #14389
Conversation
set: function(socket) { | ||
this[kSocket] = socket; | ||
if (socket && socket[async_id_symbol] === undefined) { | ||
socket[async_id_symbol] = async_hooks.newUid(); |
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.
So as we wrote in #14386 (comment)
This might not be enough. If the socket is being reused, then it might hold a socket[async_id_symbol]
but it might be stale.
[I'm not completely awake yet, but] you might want to test socket[async_id_symbol] != socket._handle.getAsyncId()
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 that is a completely different problem, this is built to be a stop-gap fixes that avoid crashing node 8 everywhere during unit tests.
The line below sets the type to 'not a socket'
, which is probably not correct in that case.
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.
This is an issue I've been wresting with for the last month while I was working on #14208. The problem with assigning an async_id
to the OutgoingMessage
is because OutgoingMessage
isn't actually asynchronous in any way, so it will never emit a before()
/after()
/destroy()
. So we're only assigning an async_id
as a stop gap.
There are two long term solutions that I could implement quickly:
-
Assign the
this[async_id_symbol] = newUid()
in theOutgoingMessage
constructor. Then use allow passing custom async_id to node::AsyncWrap::AsyncWrap #14208 to propagate that value to the socket when it's assigned. This will require detecting if thesocket
will call thedestroy()
callback, or if it needs to be queued to be called in the'finish'
event. For this to happen I'll need sign-off on said PR. -
I've also considered and experimented with assigning error codes to the
async_id_symbol
/trigger_id_symbol
that can be safely handled. In this case I'd assignUV_ENODATA
in the constructor since thesocket
hasn't been created yet, then theasync_id_symbol
can be assigned when thesocket
has been created. This has the drawback of breaking async call graphs, but is easier to implement and doesn't require the additional PR.
I'm going to step out and clear my head. Give me feedback and I can get a fix posted.
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.
@trevnorris I really like 1, and I do not really understand 2. I would prefer releasing something asap as a stop-gap solution (maybe today or tomorrow), and work on a proper fix. #14208 seems a semver-minor change, but maybe I am misreading it.
Do you think that will fix #14368 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.
👍 on (2)
IMHO if we can placate all the assertion while async_hooks
are disabled that would be best.
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.
@refack I'll start working on (2). It's a quicker solution and should address a broader scope of issues.
@mcollina (1) is a more long term solution for more specific cases and will probably require more testing to make sure it's done correctly. I'll get on that once the referenced PR lands. (2) is a way to mitigate these errors and allow bad values to flow through without crashing the process while allowing users of async_hooks
to know when bad values appear
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, I agree this can only be a stop-gap measure, but if it fixes the problems, fine by me
const { Writable } = require('stream'); | ||
const assert = require('assert'); | ||
|
||
// check that OutgoingMessage can be used without a proper 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.
Can you link to the issues in the test files? I think that would be helpful for people looking at these tests at a later point.
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
OutgoingMessage needs a async-hooks enabled socket to work, but we support also basic streams. This PR init the async-hooks bits for the passed stream if it is needed. PR-URL: nodejs#14389 Fixes: nodejs#14386 Fixes: nodejs#14381
Are we looking for a 8.2.1 today if this lands? |
@Fishrock123 considering that Hapi.js applications could not upgrade to Node 8.2 from 8.1, I would recommend either today/tomorrow/early next week. |
Even so, I think waiting for @trevnorris's PR will be prudent. P.S. @mcollina regarding |
@refack all CI systems are red with Node.js 8.2, including a lot of OSS modules. As they are red, no one will use 8.2 as of now. I stress the fact that a) we should not have released 8.2 if we knew this was happening or b) we should release a fix asap. I'm ok in reverting whatever commit caused this, but the best course of action seems a stop-gap like this one, as it is affecting only testing. |
@addaleax Unless we plan on rolling a release in the next 8 hours, let's hold off on landing this right now. I proposed a solution that should address all the issues about crashes from |
Looking at this I think our options are quite limited... I'd much rather have a temporary fix that goes out in a release later today, followed by a better and more permanent fix in a proper release in the next week or two than delay getting a fix out at all. That would likely mean landing either or both this PR or #14387 now, then doing a partial revert (keeping the test) once @trevnorris' other fix is complete. One thing I want to try to avoid is doing a Friday release, generally because those are horrible overall. This looks like a critical enough bug that we should prioritize getting a fix out today. |
@jasnell is there not a chance the release can wait 8 hours? |
8 hours yeah, that's still Thursday (here in Fresno at least ;-) ...) I just really want to avoid having to do a release tomorrow. |
Was just asking.
We did not know. Our CI and CitGM were green. |
How about you make a decision later today based on the status of the @trevnorris proposed fix? If we can get a release lined up for your end of the day, it's ok for me. |
Closing, as #14387 got released in 8.2.1 |
OutgoingMessage needs a async-hooks enabled socket to work, but
we support also basic streams. This PR init the async-hooks bits
for the passed stream if it is needed.
Fixes: #14386
Fixes: #14381
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
http, async_hooks