Skip to content

Commit

Permalink
[go] Fix hermes inspector crash from vscode-expo (expo#23271)
Browse files Browse the repository at this point in the history
# Why

when vscode-expo sending the `Runtime.callFunctionOn` event, it will crash ios expo go.
close ENG-9172

# How

compared this on top of expo-go and expo-dev-client, both reaching the line `throw std::runtime_error("unknown object id " + objId);`. only expo-go will crash the app because the exception is not caught. this happens on the new expo-go, even the older sdks (that's why this pr includes to backporting changes).
as the comment said, i still not figure out why the `std::runtime_error` is not caught by the `std::exception`. but the trick works

# Test Plan

ios expo go + sdk49 + vscode-expo debugging
  • Loading branch information
Kudo authored Jul 3, 2023
1 parent 895fafd commit 129ec18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ folly::Optional<UserCallbackException> runUserCallback(C &cb, A &&...arg) {
cb(std::forward<A>(arg)...);
} catch (const std::exception &e) {
return UserCallbackException(e);
} catch (const std::runtime_error &e) {
// NOTE(kudo): Adding this to catch Hermes inspector exceptions after SDK 49.
// I still not figure out why the std::runtime_error is not catched by the std::exception above.
return UserCallbackException(e);
}

return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ folly::Optional<UserCallbackException> runUserCallback(C &cb, A &&...arg) {
cb(std::forward<A>(arg)...);
} catch (const std::exception &e) {
return UserCallbackException(e);
} catch (const std::runtime_error &e) {
// NOTE(kudo): Adding this to catch Hermes inspector exceptions after SDK 49.
// I still not figure out why the std::runtime_error is not catched by the std::exception above.
return UserCallbackException(e);
}

return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ std::optional<UserCallbackException> runUserCallback(C &cb, A &&...arg) {
cb(std::forward<A>(arg)...);
} catch (const std::exception &e) {
return UserCallbackException(e);
} catch (const std::runtime_error &e) {
// NOTE(kudo): Adding this to catch Hermes inspector exceptions after SDK 49.
// I still not figure out why the std::runtime_error is not catched by the std::exception above.
return UserCallbackException(e);
}

return {};
Expand Down
2 changes: 1 addition & 1 deletion react-native-lab/react-native

0 comments on commit 129ec18

Please sign in to comment.