-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stable error handling for loaded Cordova plugins #222
base: master
Are you sure you want to change the base?
Conversation
Platforms affected All Motivation and Context When developing a large Cordova app in a distributed team occasionally a developer commits a Cordova plugin which contains an issue which directly results in a javaScript exception on plugin load. Before the fix the Cordova startup crashes and the app results in a whitescreen. Description The fix makes handlePluginsObject more stable. The function keeps track of the loaded modules. If a load error occurs for a module the module is removed from the modules list. Additionally an alert is displayed. This makes it way easier for developers to track and fix the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. 👍
I have left two suggestions to simplify the code. It would be great if you could see if they work for you. Unit tests for this feature would be nice as well.
One other thought: It might be better if we only show one message in the end with all problems aggregated. Opinions?
This pointer not needed. Therefore not bound. Co-Authored-By: Raphael von der Grün <raphinesse@gmail.com>
Regarding one consolidated error message I had two thoughts in mind:
Before the PR is not accepted I will create a consolidated error message but I feel more comfortable with the existing solution. |
Co-Authored-By: Raphael von der Grün <raphinesse@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #222 +/- ##
=========================================
Coverage ? 82.88%
=========================================
Files ? 14
Lines ? 555
Branches ? 0
=========================================
Hits ? 460
Misses ? 95
Partials ? 0 Continue to review full report at Codecov.
|
Do you have any suggestions on how to hook into the functionality? This will save me some debugging. The existing unit tests are of higher level. |
@mathiasscheffe Good points about the error messages. I think having separate messages should be fine then.
I think you should be able to define a fake
No hurry. All in due time. |
Another important point that should be considered is the following: I see the appeal of alert during development, so you notice your mistake ASAP. But under no circumstances should Cordova show an alert in a released App. Network or file system issues could cause this in the current version of this PR AFAICT. What can we do to prevent this? |
I have changed the approach here. I have removed the alert() and have left a comment. P.S.: Will make time until end of week to also implement unit tests. |
The pull request now also contains unit tests for the newly added functionality. |
Platforms affected
All
Motivation and Context
When developing a large Cordova app in a distributed team occasionally a developer commits a Cordova plugin which contains an issue which directly results in a javaScript exception on plugin load.
Before the fix the Cordova startup crashes and the app results in a whitescreen.
This can also happen if the plugin uses ES6+ features and the client installs the app on an e.g. older Android device. Such cases should be found during regression testing but sometimes it is just overlooked. With this fix the client gets a descriptive error message.
Description
The fix makes handlePluginsObject more stable. The function keeps track of the loaded modules. If a load error occurs for a module the module is removed from the modules list. Additionally an alert is displayed. This makes it way easier for developers to track and fix the error.
Testing
The 4 existing unit tests of pluginmanager are very high level. If somebody can outline a test idea for the introduced logic I am happy to implement.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)