-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Documentation on runtime.connect does not address manifest V3 background scripts dropping ports when they drop off after inactivity #36097
Comments
By the way, I am using the Firefox Browser Console tool to capture the log console log entries, so as to prevent the presence of the extension Inspect tool from throwing warning messages indicating that hooks from the Inspect tool were preventing the background script from being unloaded. |
Also, the background script is being loaded from a background.html file specified in the manifest. |
I attempted to reproduce this issue using the extension and steps outlined in this gist. I suspect that the problem you're running into is that the To fix this issue, move the |
The browser.runtime.onConnect.addListener() call is not within any function, but rather placed at the 'top level' of statements. Also, I suspect the issue may be related to the background script being called from a background.html page referenced in the manifest.json file. |
After looking closely at your gist, I noticed 2 things you are using that I am not.
Also, I am limiting my extension to a specific domain (youtube.com) rather than matching to any url |
Neither of those differences should affect the this case. I also don't expect that the difference between the host permission patterns would have any affect here. Could you share a version of the extension that demonstrates the problem? Also, what version of Firefox and operating system are you using? That info may be relevant for investigation purposes. |
MDN URL
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/connect
What specific section or headline is this issue about?
Examples
What information was incorrect, unhelpful, or incomplete?
When trying to create a V3 browser extension, I am finding that the extension background page is unloaded (as expected) after a period of inactivity. This creates a Port.onDisconnect event in the content script from which the connection was initiated, but often results in the inability to successfully open a new port to the background script if inactivity is about 20 seconds or more.
What did you expect to see?
I expected to see some direction regarding how to successfully and reliably reconnect to the background script after it gets unloaded.
Do you have any supporting links, references, or citations?
Extension Testing.txt
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/mozilla/add-ons/webextensions/api/runtime/connect
The text was updated successfully, but these errors were encountered: