Manifest v3: Native Messaging Service Worker is "inactive" upon launch

131 views
Skip to first unread message

Jerry Krinock

unread,
Sep 7, 2023, 9:17:12 PM9/7/23
to Chromium Extensions
In recent versions of Google Chrome, currently version 116, if you install an unpacked manifest v3 extension with Native Messaging implemented in a Service Worker, and then quit and relaunch Chrome, the Native Messaging Host does not launch as expected, the word "inactive" appears after the service worker's hyperlink in the Extensions tab, and of course the extension does not respond to Native Messages from its native app.  Native Messaging commences if I open the Extensions tab and click on the  service worker's hyperlink.

This is bad behavior for extensions such as bookmarks syncing which must work without any user action in Chrome.  The bad behavior does not occur if I install as unpacked my old manifest v2 extension which implements Native Messaging in a Background Page.  So it seems like the bad behavior is not an artifact of the extension being loaded as unpacked.  (I cannot tell for sure since I don't know of any way to side-load a packed extension.)  The result is that.I cannot confidently replace my old manifest v2 extension with my new manifest v3 update.  What can I do?

Here is a video which shows this behavior in action.

kg_17

unread,
Sep 8, 2023, 1:16:51 AM9/8/23
to Chromium Extensions, Jerry Krinock
Save this line of code in your service worker:

chrome.runtime.onStartup.addListener(() => {});

Then reload your extension and restart Chrome.  The service worker will be active on startup.

Jerry Krinock

unread,
Sep 8, 2023, 9:24:45 AM9/8/23
to Chromium Extensions, kg_17, Jerry Krinock
Thank you, kg.  It works as you said.  Problem solved.
Reply all
Reply to author
Forward
0 new messages