Skip to content

Commit

Permalink
Report native module name on crash when native module has failed to l…
Browse files Browse the repository at this point in the history
…oad (#24633)

Summary:
After upgrading RN from 0.57 to 0.59.4 we've received a lot of crash reports like `Exception in HostObject::get: <unknown>`  with no clue what native module caused the crash. This commit adds native module name on crash in this situations. Related to #24607.

[General] [Added] - Report native module name on crash when native module has failed to load
Pull Request resolved: #24633

Differential Revision: D15120225

Pulled By: cpojer

fbshipit-source-id: cf8e3e5953548a58f1d010eb70343da5ee946ae8
  • Loading branch information
Dmitry Dushkin authored and facebook-github-bot committed Apr 29, 2019
1 parent 9fba855 commit 6ab249f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ReactCommon/jsi/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ class JSCRuntime : public jsi::Runtime {
static JSStringRef stringRef(const jsi::String& str);
static JSStringRef stringRef(const jsi::PropNameID& sym);
static JSObjectRef objectRef(const jsi::Object& obj);

#ifdef RN_FABRIC_ENABLED
static JSObjectRef objectRef(const jsi::WeakObject& obj);
#endif

// Factory methods for creating String/Object
jsi::Symbol createSymbol(JSValueRef symbolRef) const;
jsi::String createString(JSStringRef stringRef) const;
Expand Down Expand Up @@ -688,7 +688,7 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
auto excValue =
rt.global()
.getPropertyAsFunction(rt, "Error")
.call(rt, "Exception in HostObject::get: <unknown>");
.call(rt, std::string("Exception in HostObject::get: ") + JSStringToSTLString(propertyName));
*exception = rt.valueRef(excValue);
return JSValueMakeUndefined(ctx);
}
Expand Down Expand Up @@ -1359,14 +1359,14 @@ JSStringRef JSCRuntime::stringRef(const jsi::PropNameID& sym) {
JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) {
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}

#ifdef RN_FABRIC_ENABLED
JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) {
// TODO: revisit this implementation
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}
#endif

void JSCRuntime::checkException(JSValueRef exc) {
if (JSC_UNLIKELY(exc)) {
throw jsi::JSError(*this, createValue(exc));
Expand Down

0 comments on commit 6ab249f

Please sign in to comment.