From 2eb02c5adc11a681f2c4efc0640c547ccec3aaf4 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 31 Jul 2021 07:20:38 -0400 Subject: [PATCH] Fix spurious error message in dev console Ports can be disconnected under certain conditions, and in such case runtime.lastError must be accessed to avoid the extensions framework from emitting error messages in the console. --- platform/common/vapi-client.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/common/vapi-client.js b/platform/common/vapi-client.js index 1b585fd64..3a3f691e4 100644 --- a/platform/common/vapi-client.js +++ b/platform/common/vapi-client.js @@ -97,9 +97,12 @@ vAPI.messaging = { // as world-ending, i.e. stay around. Except for embedded frames. disconnectListener: function() { + void browser.runtime.lastError; this.port = null; if ( window !== window.top ) { vAPI.shutdown.exec(); + } else { + this.destroyPort(); } }, disconnectListenerBound: null, @@ -129,11 +132,10 @@ vAPI.messaging = { messageListenerBound: null, canDestroyPort: function() { - return this.pending.size === 0 && - ( - this.extensions.length === 0 || - this.extensions.every(e => e.canDestroyPort()) - ); + return this.pending.size === 0 && ( + this.extensions.length === 0 || + this.extensions.every(e => e.canDestroyPort()) + ); }, mustDestroyPort: function() {