Skip to content

Commit

Permalink
If getters throw, replace value with a placeholder
Browse files Browse the repository at this point in the history
Summary:
Currently, if you try to inspect globals in the debugger and they have
properties that throw exceptions, the app redscreens.  In particular,
inspecting any function triggers the bug because of `arguments` and
`caller`.

This diff catches the exception and shows a placeholder instead.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D18664765

fbshipit-source-id: 0c662f3d97b21a29c57a1dd724e63d17a3b4e263
  • Loading branch information
willholen authored and facebook-github-bot committed Nov 23, 2019
1 parent 1610c08 commit d0ed215
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ReactCommon/hermes/inspector/chrome/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,21 @@ Connection::Impl::makePropsFromValue(
m::runtime::PropertyDescriptor desc;
desc.name = propName.utf8(runtime);

jsi::Value propValue = obj.getProperty(runtime, propName);
desc.value = m::runtime::makeRemoteObject(
runtime, propValue, objTable_, objectGroup);
try {
// Currently, we fetch the property even if it runs code.
// Chrome instead detects getters and makes you click to invoke.
jsi::Value propValue = obj.getProperty(runtime, propName);
desc.value = m::runtime::makeRemoteObject(
runtime, propValue, objTable_, objectGroup);
} catch (const jsi::JSError &err) {
// We fetched a property with a getter that threw. Show a placeholder.
// We could have added additional info, but the UI quickly gets messy.
desc.value = m::runtime::makeRemoteObject(
runtime,
jsi::String::createFromUtf8(runtime, "(Exception)"),
objTable_,
objectGroup);
}

result.emplace_back(std::move(desc));
}
Expand Down

0 comments on commit d0ed215

Please sign in to comment.