Uh oh!
There was an error while loading. Please reload this page.
util: fix constructor/instanceof checks - #3385
Conversation
evanlucas
commented
Oct 15, 2015
LGTM. is there anywhere else we are relying on similar functionality? |
mscdex
commented
Oct 15, 2015
Yeah, I guess I'll fix those up too while I'm in there. |
332647b to
68e2f1eCompareThere was a problem hiding this comment.
Should this be typeof obj !== 'undefined' or obj !== undefined, like above?
mscdex
commented
Oct 15, 2015
Updated to fix the other constructor/instanceof checks. CI: https://ci.nodejs.org/view/iojs/job/node-test-pull-request/515 |
68e2f1e to
0450980Compareevanlucas
commented
Oct 15, 2015
Just curious, but I wonder if the |
mscdex
commented
Oct 15, 2015
Updated again to fix typo. CI: https://ci.nodejs.org/view/iojs/job/node-test-pull-request/516 |
vkurchatkin
commented
Oct 15, 2015
This doesn't seem better than |
0450980 to
f8cb886Comparemscdex
commented
Oct 15, 2015
@vkurchatkin That won't work for Promises though. I've now replaced |
targos
commented
Oct 15, 2015
@mscdex I don't know if Map and Set can be subclassed, but I think your first version had the advantage to catch this: classMyMapextendsMap{}util.inspect(newMyMap) |
mscdex
commented
Oct 15, 2015
@targos They can be and apparently CI after replacing Map/Set check implementations: https://ci.nodejs.org/view/iojs/job/node-test-pull-request/517/ |
evanlucas
commented
Oct 21, 2015
I'm still a little concerned about using |
mscdex
commented
Oct 21, 2015
@evanlucas Unreliable in what way? We're already using the same method in other |
evanlucas
commented
Oct 21, 2015
maybe I'm thinking about once |
evanlucas
commented
Oct 21, 2015
LGTM if CI is happy |
jasnell
commented
Oct 21, 2015
As much as depending on |
mscdex
commented
Oct 21, 2015
@jasnell Well, previously I was walking the prototype chain (similar to what I'm currently doing for checking for promises), but I'm not sure what the performance differences are. |
jasnell
commented
Oct 21, 2015
Yeah, like I said, I'm not sure there's a better way. It just makes me sad to be forced to rely on toString checks |
jasnell
commented
Oct 22, 2015
Kicked off another CI run, just to be sure since the last one came up red: https://ci.nodejs.org/job/node-test-pull-request/567/ |
jasnell
commented
Oct 22, 2015
@mscdex .. hmm... thinking... would this qualify as a semver-minor or major? it likely shouldn't but want to be sure |
mscdex
commented
Oct 22, 2015
Wow, looks like there's something missing from a previous commit... an addon test is looking for a debug module... |
mscdex
commented
Oct 22, 2015
Personally I would see this as a bug fix, so I wouldn't see it as a |
jasnell
commented
Oct 22, 2015
Very odd... testing a clean build locally on osx... |
jasnell
commented
Oct 22, 2015
@mscdex ... not seeing the same failure locally on osx ... can you test on your end? |
trevnorris
commented
Oct 23, 2015
FWIW calling into native is cheap, the call itself is simple enough: voidCheckIsPromise(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(args[0]->IsPromise());
}And this method is more definitive. |
jasnell
commented
Nov 5, 2015
New CI: https://ci.nodejs.org/job/node-test-pull-request/676/ @mscdex ... did you see the last comment from @trevnorris ? |
f8cb886 to
cdd15fbComparemscdex
commented
Nov 5, 2015
@jasnell I've removed the js |
There was a problem hiding this comment.
What do you mean? A mirror is still only created if it's been determined the object is a promise. Do you mean the "superficially" part?
There was a problem hiding this comment.
Yes, now the check isn't superficial. Also the comment isn't in the right context. It is not obvious here that we create an object mirror.
I know the change was made earlier but do you mind moving it to the inspectPromise declaration ?
There was a problem hiding this comment.
I personally think it's fine the way it is.
jasnell
commented
Nov 5, 2015
LGTM. CI is red but the failures do not appear to be related. |
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead.
cdd15fb to
7b775daComparemscdex
commented
Dec 1, 2015
@targos I've updated the comment about Promises. LGTY? |
mscdex
commented
Dec 1, 2015
I ran through CI one more time and only saw a few unrelated errors on Windows. |
targos
commented
Dec 1, 2015
LGTM |
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead. PR-URL: #3385 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
mscdex
commented
Dec 1, 2015
Landed in 82b8355. |
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead. PR-URL: #3385 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead. PR-URL: #3385 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead. PR-URL: #3385 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead. PR-URL: nodejs#3385 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
util: fix constructor/instanceof checks
These new checks are similar to the one introduced in 089d688, but for other types of objects. Specifically, if an object was created in a different context, the constructor object will not be the same as the constructor object in the current context, so we have to compare constructor names instead.