From 4d68d7f586bab3c692f6648c4af7fd49e8dff395 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 2 Dec 2020 10:07:14 -0500 Subject: [PATCH] Fix handling of no-longer-existing port condition The condition has been spotted occurring when bringing up the DOM inspector for a page on which cosmetic filters are being applied. Not clear why this happens, but uBO must be ready to graciously handle such condition. --- platform/chromium/vapi-background.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index d48071184..36fdf742b 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -959,7 +959,7 @@ vAPI.messaging = { try { port.postMessage(messageWrapper); } catch(ex) { - this.ports.delete(port.name); + this.onPortDisconnect(port); } } }, @@ -985,7 +985,11 @@ vAPI.messaging = { msg.tabId = tabId; for ( const { port: toPort } of this.ports.values() ) { if ( toPort === port ) { continue; } - toPort.postMessage(request); + try { + toPort.postMessage(request); + } catch (ex) { + this.onPortDisconnect(toPort); + } } break; case 'connectionBroken':