Error: WebExtension context not found!
Categories
(WebExtensions :: General, defect, P3)
Tracking
(firefox61 affected)
Tracking | Status | |
---|---|---|
firefox61 | --- | affected |
People
(Reporter: kmag, Unassigned)
References
()
Details
(Whiteboard: [nightly-js-sentry:2045118])
Reporter | ||
Updated•7 years ago
|
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Comment 2•6 years ago
|
||
Updated•6 years ago
|
Comment 3•6 years ago
|
||
I'm finding this error in my logs, and I have no idea whether this error is relevant to the problem I am trying to debug or whether this message is noise from something else.
Someone hunted down the code, and we have an excessive vague error message:
https://stackoverflow.com/questions/49051084/firefox-console-error-webextension-context-not-found
getContextById(childId) {
let context = this.proxyContexts.get(childId);
if (!context) {
let error = new Error("WebExtension context not found!");
Cu.reportError(error);
throw error;
}
return context;
}
The message "WebExtension context not found!" should be "WebExtension context '" + childId + "' not found!".
Updated•2 years ago
|
Comment 4•3 months ago
|
||
This error can occur when an extension API is called shortly before the context disappears.
Bug 1905505 is an example where many errors like these were triggered: in that case the event page terminated too soon, and any pending extension API calls arrived over IPC after the context went away.
Here is a relevant comment about the implementation detail:
- ParentAPIManager.recvAPICall resets the timer before processing an API call. Before it gets there, it looks up the context via
getContextById
, which throws if the context has already been unloaded. Experimentally I confirmed that unloading the background event browser viasetBgStateStopped
triggers a synchronousmessage-manager-close
notification that erases the context. If we ever decide to drop the use of this notification in favor of recvConduitClosed (which is tracked in bug 1595186), then we have to carefully examine that doing so will not cause bugs like this ("this" referring to bug 1905505).
Bug 1595186 is about moving away from message-manager-close to Conduits, which would slightly extend the lifetime of a "context" in the parent until when all API calls and messages from the content has been processed (recvConduitClosed). Doing so would reduce the frequency of this reported error because then the recvAPICal / recvAddListener / etc. handlers would use the same IPC mechanism as the "context unload" mechanism.
If changing the timing of "context unload" is undesirable, then we could still reduce the number of reported errors by temporarily storing the ID when at message-manager-close, until recvConduitClosed (and use the presence of the ID to suppress the error message or make it more useful).
Description
•