-
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
repl: Prevent REPL crash when tab-completed with Proxy objects #2120
Conversation
I don't know how to write a test for this, as we need to
I am not sure how to do both of them in the same test. |
To force the flags, take a look at https://github.com/nodejs/io.js/blob/master/test/sequential/test-debug-args.js#L2 |
Can something else except proxy objects cause Also, I'm not sure adding an error message is useful. Maybe just silencing that particular error would be better. |
@evanlucas I tried that now and it doesn't work. This is the patch which I tried,
It still throws a @rlidwka We can tighten the error checking, but silencing it will not give a hint to the user. Will that be okay? |
Did you still get the ReferenceError running it with |
@evanlucas Awesome, it works :-) Thanks for the help. I removed the error check as suggested by @rlidwka now. |
46d7896
to
df87261
Compare
'var proxy = Proxy.create({});' | ||
]); | ||
|
||
testMe.complete('proxy.', function(error, data) { |
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.
Please use either the referenceErrors
or completionCount
variable here (see the rest of the test). This test is known to fail silently.
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.
@cjihrig Oh, why not common.mustCall
then? That should work here, right? I think that would make the tests better, without explicitly counting.
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.
That should work for the tests using completionCount
.
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 can no longer be merged. |
Not a huge fan of just dropping errors, but it's also just REPL tab completion. LGTM |
b77a4c9
to
c598b9a
Compare
If the proxy objects don't have a valid `hasOwnPropertyNames` trap, REPL crashes with a `TypeError`, as per the bug report nodejs#2119 > var proxy = Proxy.create({ fix: function() { return {}; } }); undefined > proxy.<tab> TypeError: Proxy handler #<Object> has no 'getOwnPropertyNames' trap at Function.getOwnPropertyNames (native) at repl.js:644:40 at REPLServer.defaultEval (repl.js:169:5) at bound (domain.js:254:14) at REPLServer.runBound [as eval] (domain.js:267:12) at REPLServer.complete (repl.js:639:14) at REPLServer.complete [as completer] (repl.js:207:10) at REPLServer.Interface._tabComplete (readline.js:377:8) at REPLServer.Interface._ttyWrite (readline.js:845:14) at ReadStream.onkeypress (readline.js:105:10) This patch traps the error thrown and suppresses it.
c598b9a
to
fc1ae90
Compare
@cjihrig Thanks for reviewing and notifying about the merge conflict :-) I rebased and squashed the commits. @rlidwka @evanlucas PTAL :-) |
CI: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/139/ LGTM if CI is happy |
If the proxy objects don't have a valid `hasOwnPropertyNames` trap, REPL crashes with a `TypeError`, as per the bug report #2119 > var proxy = Proxy.create({ fix: function() { return {}; } }); undefined > proxy.<tab> TypeError: Proxy handler #<Object> has no 'getOwnPropertyNames' trap at Function.getOwnPropertyNames (native) at repl.js:644:40 at REPLServer.defaultEval (repl.js:169:5) at bound (domain.js:254:14) at REPLServer.runBound [as eval] (domain.js:267:12) at REPLServer.complete (repl.js:639:14) at REPLServer.complete [as completer] (repl.js:207:10) at REPLServer.Interface._tabComplete (readline.js:377:8) at REPLServer.Interface._ttyWrite (readline.js:845:14) at ReadStream.onkeypress (readline.js:105:10) This patch traps the error thrown and suppresses it. PR-URL: #2120 Fixes: #2119 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Landed in 59f6b5d with a slightly modified commit message to conform to the collaborator guidelines. Thanks @thefourtheye! |
@evanlucas Thanks :-) Can we close the actual bug report now itself or we ll wait for the fix to be released? |
Good call. I forgot about that. Done |
If the proxy objects don't have a valid
hasOwnPropertyNames
trap,REPL crashes with a
TypeError
, as per the bug report#2119
This patch traps the error thrown and issues Error message.