Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: polyfill.js

Issue 29582716: Issue 4579 - Ignore runtime.lastError caused by wrapper (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Add old error message with typo Created Oct. 20, 2017, 1:09 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: polyfill.js
===================================================================
--- a/polyfill.js
+++ b/polyfill.js
@@ -38,16 +38,25 @@
"tabs.sendMessage",
"tabs.update",
"webNavigation.getAllFrames",
"webRequest.handlerBehaviorChanged",
"windows.create",
"windows.update"
];
+ // Errors that occur only when we show an interest in the response from an
+ // API call.
+ const noFulfillmentErrors = new Set([
+ "The message port closed before a response was received.",
+ // Older versions of Chrome have a typo:
+ // https://crrev.com/c33f51726eacdcc1a487b21a13611f7eab580d6d
+ "The message port closed before a reponse was received."
+ ]);
Sebastian Noack 2017/10/20 01:26:30 Perhaps, we can just use a regexp to account for t
Manish Jethani 2017/10/20 01:45:32 Yes, using a regex now. The commit was on June 30
+
function wrapAPI(api)
{
let object = browser;
let path = api.split(".");
let name = path.pop();
for (let node of path)
{
@@ -71,17 +80,17 @@
if (typeof args[args.length - 1] == "undefined")
args.pop();
return new Promise((resolve, reject) =>
{
func.call(object, ...args, result =>
{
let error = browser.runtime.lastError;
- if (error)
+ if (error && !noFulfillmentErrors.has(error.message))
reject(error);
else
resolve(result);
});
});
};
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld