Skip to content

Conversation

Informate
Copy link

@Informate Informate commented Feb 11, 2025

GitHub Issues: #14177

Optional Description:

The unhandledRejection V8 event is unhandled by Titanium SDK at the moment, and the unhandledRejections event get silently lost.

This commit fixes the issue handling the V8 event and sending it from V8Runtime to the JS environment thorw Kroll with just few changes and modify.

The JS Error Dialog shows correctly and the Rejected Promises can now be cacthed by uncaughtException as an exception with type='Rejected Promise' (still not a Ti.App unhandledRejection event).

Code Example:

Ti.App.addEventListener('uncaughtException',(err)=>console.error(err));
(async ()=>{
  throw new Error("Show me this ERROR !!!!");
})();

@Informate Informate changed the title [14177] Global UnhandledRejection redirector to JSDialogError and uncaughrException handler [14177] Global UnhandledRejection redirector to JSDialogError and uncaughtException handler Feb 11, 2025
@Informate Informate changed the title [14177] Global UnhandledRejection redirector to JSDialogError and uncaughtException handler [14177] Android: Global UnhandledRejection redirector to JSDialogError and uncaughtException handler Feb 11, 2025
@m1ga
Copy link
Contributor

m1ga commented Feb 11, 2025

Please check https://www.fromzerotoapp.com/extending-titanium-sdk/#link9 and rename the title according to it. This should be a feat(andorid).... and make sure to add the example code to test it in the description.

@Informate Informate changed the title [14177] Android: Global UnhandledRejection redirector to JSDialogError and uncaughtException handler Feat (Android): Global UnhandledRejection redirector to JSDialogError and uncaughtException handler Feb 13, 2025
@Informate
Copy link
Author

Please check https://www.fromzerotoapp.com/extending-titanium-sdk/#link9 and rename the title according to it. This should be a feat(andorid).... and make sure to add the example code to test it in the description.

Renamed! There something more I have to do? Need to resubmit the PR or not?

@m1ga m1ga changed the title Feat (Android): Global UnhandledRejection redirector to JSDialogError and uncaughtException handler feat (android): global UnhandledRejection redirector to JSDialogError and uncaughtException handler Feb 13, 2025
@m1ga
Copy link
Contributor

m1ga commented Feb 13, 2025

@Informate no, you don't need to resubmit it.

Please add the code example to the first post (edit it) so people know how to test it.

@Informate
Copy link
Author

@Informate no, you don't need to resubmit it.

Please add the code example to the first post (edit it) so people know how to test it.

Done

Copy link
Contributor

@m1ga m1ga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test:

  • current master will not show an error with the provided demo code
  • this PR will show
[ERROR] V8Util: Uncaught Error: Show me this ERROR !!!!
[ERROR] V8Util: /alloy/controllers/index.js @ 48 >>> throw new Error("Show me this ERROR !!!!");
[ERROR] TiExceptionHandler: (main) [49,49] /alloy/controllers/index.js:48
[ERROR] TiExceptionHandler: throw new Error("Show me this ERROR !!!!");
[ERROR] TiExceptionHandler:       ^
[ERROR] TiExceptionHandler: Error: Show me this ERROR !!!!
[ERROR] TiExceptionHandler:     at /alloy/controllers/index.js:48:7
[ERROR] TiExceptionHandler:     at new Controller (/alloy/controllers/index.js:49:3)
[ERROR] TiExceptionHandler:     at Object.exports.createController (/alloy.js:427:8)
[ERROR] TiExceptionHandler:     at /app.js:32:7
[ERROR] TiExceptionHandler:     at Module._runScript (ti:/kroll.js:1196:15)
[ERROR] TiExceptionHandler:     at Module.load (ti:/kroll.js:734:13)
[ERROR] TiExceptionHandler:     at Module.loadJavascriptText (ti:/kroll.js:1062:15)
[ERROR] TiExceptionHandler:     at Module.loadAsFile (ti:/kroll.js:1108:22)
[ERROR] TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/kroll.js:1039:26)
[ERROR] TiExceptionHandler:     at Module.require (ti:/kroll.js:865:30)
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:172)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiApplication.launch(TiApplication.java:881)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:96)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:508)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:177)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.onResume(TiRootActivity.java:527)
[ERROR] TiExceptionHandler:     android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1717)
[ERROR] TiExceptionHandler:     android.app.Activity.performResume(Activity.java:9315)
[ERROR] TiExceptionHandler:     android.app.ActivityThread.performResumeActivity(ActivityThread.java:5605)

as an error log and the error message in the event has more infos like the stack and stacktrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants