In Bridge.js there's an access to val.__proto__[name], which seems like it should be okay. However, it is possible to define a getter that expects a complete instance, rather than a empty prototype.
For instance:
var proto = {
get upperName() { return this.name.toUpperCase()}
};
var instance = Object.create(proto);
instance.name = 'Foo';
console.log(instance.upperName); //=> FOO
console.log(instance.__proto__.upperName); //Throws: Cannot read property 'toUpperCase' of undefined
Bridge.js could
result upon an exception.defineProperty any getters on the __proto__ so they continue to refer to the same instance. Any readout could then throw (i.e. result.__proto__.upperName still throws), but referring tto result[name] would not throw.__proto__ instead upon an exception.It seems to me the value should show somewhere, rather than an error displayed. In any case, as it stands now, it breaks the extension. The error can only be found in the console.
Also, property getters could throw for reasons other than an instance/proto issue. It's probably a good idea to catch errors thrown and display the error in the UI, rather than aborting the code flow of the extension. It could be as simple as storing the error as a string on the property or just calling dehydrate(err) on the caught error.
I'm having the same issue with kotlin.js. List defines size property with custom getter. It expects full instance, not just prototype. Now it crashes when trying to inspect it when part of the props.
Crashes on this line:
newProto[name] = dehydrate(val.__proto__[name], protoclean, [name]);
We could probably use getOwnPropertyDescriptor to detect things that have getters & dehydrate them specially (chrome devtools does this, rendering the value as ... until you click it & force evaluation)
Eval on request is technically superior since getters can have side effects.
Running into this in slate as well with getters defined.
PR #469 fixes this issue as well.
Happy to accept a standalone fix for this!
We could probably use getOwnPropertyDescriptor to detect things that have getters & dehydrate them specially (chrome devtools does this, rendering the value as ... until you click it & force evaluation)
This is what we should do.
It would also allow us to unrevert https://github.com/facebook/react-devtools/pull/517 again, and thus fix https://github.com/facebook/react-devtools/issues/288.
Thinking about work on this. Want to clarify how it should be done:
getOwnPropertyDescriptorNot sure how implement last point, so tips will be useful.
Not sure how implement last point, so tips will be useful.
I'm not sure either鈥擨 think you should give it a try and see what works 馃槢 You'll want to have access to the getter and the target object so that you can call the getter when necessary. What you described sounds reasonable to me.
@zinoviev Just to be clear, are you still planning to implement this?
@gaearon Yep, already started
Awesome, thanks!
Take a look at PR plz https://github.com/facebook/react-devtools/pull/569

Niiiiice. I will next week! If I don鈥檛 please ping me again.
Good day everyone! Did you fix this problem? When I try to call object with getters I can't get their values and get errors for them if they are calling other getters ;(
@RuBAN-GT Yep, still waiting for merge
React DevTools has been rewritten and recently launched a new version 4 UI. The source code for this rewrite was done in a separate repository and now lives in the main React repo (github.com/facebook/react).
Because version 4 was a total rewrite, and all issues in this repository are related to the old version 3 of the extension, I am closing all issues in this repository. If you can still reproduce this issue, or believe this feature request is still relevant, please open a new issue in the React repo: https://github.com/facebook/react/issues/new?labels=Component:%20Developer%20Tools
Most helpful comment
We could probably use
getOwnPropertyDescriptorto detect things that have getters & dehydrate them specially (chrome devtools does this, rendering the value as...until you click it & force evaluation)