JaneaSystems / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://code.janeasystems.com/nodejs-mobile
Other
2.57k stars 183 forks source link

[nodejs-mobile-react-native] App exits abruptly on exception in main.js #288

Open GrabbenD opened 3 years ago

GrabbenD commented 3 years ago

Whenever there's an exception such as typeerror in main.js, the app exits abruptly. Is there any way to prevent this behaviour? For instance, wrapping the code inside a try/catch doesn't always work.

To reproduce the issue, try this in main.js:

const rn_bridge = require('rn-bridge');
throw new Error("Test");
jonesne92 commented 3 years ago

I found that I could debug the nodejs code using adb logcat -s "nodejs" (filters logcat logs by "nodejs" tag)

Porizm commented 3 years ago

Hello, I know to too late for this, put this at the top of your main.js to prevent app from exiting on error.

process.on('uncaughtException', function (e) { Error.captureStackTrace(e); });