Difference between runtime.onInstalled and runtime.onUpdateAvailable?

The MDN pages for these two events read as almost identical. When is one used and the other not used, or do both always need to be used in an extension?

Neither needs to be used for the extension to work.

Fired only once when the current extension version is installed.
Fired when a newer version of the extension becomes available for download from the browser’s extension store.

Incorrect: according to MDN, ignoring these can cause an extension to be updated while it is in operation. In my case, for a password manager, this can have undetermined results.

Incorrect. Also fired when the extension is updated.

As I read the docs:

  • runtime.onInstalled is fired when your extension has just been installed or updated. Use it if you want to do something once your extension has been installed/updated.

  • runtime.onUpdateAvailable is fired when the browser wants to update your extension, but it hasn’t, yet. The behavior of runtime.onUpdateAvailable is that, if you are listening to it, then the update will not be applied until your extension is reloaded. So you can listen to this event while you are doing something that should not be interrupted by an update. It’s a little unusual for an event listener in that just the act of listening to the event changes the browser’s behavior.

wbamberg, Thank you! I just could see no difference at all, but what you’re saying makes sense. I did not expect that listening to an event would prevent updating, but this is really useful. If I knew for sure that you are correct, I would edit the two MDN pages to make the difference clearer. Maybe someone else will do the editing. Thanks again.

But that doesn’t mean that the extension won’t work if they’re not being used.

I said when the current version is installed, which implies updates.