HomePhabricator
Diffusion Comm 49d61c26c1b5

Transform C++ error to JSError on the main thread

Description

Transform C++ error to JSError on the main thread

Summary: In https://phab.comm.dev/D4650 we enabled informative JSError to be thrown when SQLite query fails on databaseThread of CommCoreModule. I tested it only on emulators and it worked. However on physical devices I found out that I cannot access jsi::Runtime passed to function from auxiliary thread. Context is here https://github.com/react-native-community/discussions-and-proposals/issues/196. This diff updates the code so that we only catch C++ error in database thread and transform it to JSError on the main thread. This change also solves the crash described here: https://linear.app/comm/issue/ENG-1714/ashoat-experienced-5-crashes-in-one-day-on-build-142

Test Plan: Place temporary 'throw std::system_error(ECANCELED, std::generic_category(), "error");' at the begining of SQLiteWueryExecutor::getAllMessages. Build and start the app. Without this diff it will crash. With this diff it will throw informative JSError.

Reviewers: tomek, atul, jon

Reviewed By: tomek

Subscribers: ashoat, abosh

Differential Revision: https://phab.comm.dev/D4976

Details

Provenance
marcinAuthored on Sep 26 2022, 5:58 AM
Reviewer
tomek
Differential Revision
D4976: Transform C++ error to JSError on the main thread
Parents
rCOMM8e2208623fcd: [web] Added possibility to change input type and icon position in…
Branches
Unknown
Tags
Unknown