From 7e5396a11db72efa191ef43c34c88b110f8c1524 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 26 Aug 2017 07:51:28 +0300 Subject: [PATCH] prevent browser exception bug on sendResponse to a closed tab fixes #171 --- background/background.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/background/background.js b/background/background.js index 5026fa53..44e09795 100644 --- a/background/background.js +++ b/background/background.js @@ -320,6 +320,14 @@ function updateIcon(tab, styles) { function onRuntimeMessage(request, sender, sendResponse) { + // prevent browser exception bug on sending a response to a closed tab + sendResponse = (sendResponseOriginal => + data => { + try { + sendResponseOriginal(data); + } catch (e) {} + } + )(sendResponse); switch (request.method) { case 'getStyles': getStyles(request).then(sendResponse);