Restart my extension when it crashes (JS exception preventing user of using the extension)

98 views
Skip to first unread message

Osny Santos Netto

unread,
Nov 19, 2017, 11:59:49 AM11/19/17
to Chromium-Extensions-Announce
I'm creating a extension and I'm doing my best to now allow any JS exception but there's times where it happen, usually when it happens the user got stuck (any click doesnt work anymore). And for the end user it's impossible to get it working again because he can't simply reload the extension. Just restarting the chrome entirely.

I wonder if there's an option to reload the extension automatically when this scenario happen (JS Exception). Maybe adding an option clicking with right button inside the extension icon and creating a menu called "Restart extension" or something else. I'm not sure what's the best alternative but I'm really looking for one option to offer the user to get unstack when this happen.

Devlin Cronin

unread,
Nov 21, 2017, 12:42:12 PM11/21/17
to Chromium-Extensions-Announce
The best solution really depends on the UX you want and the scenarios in which this can happen.  An extension can restart itself through the chrome.runtime.reload method.  It's up to you when to call this, though.  You can surface it through the extension icon's menu by adding a menu item on the action through the contextMenus API, or you could try and detect a bad state in some other way.

Note that reloading the extension will result in closing any open extension tabs, severing all port connections, etc, so it should be used sparingly.
Reply all
Reply to author
Forward
0 new messages