Skip to content

Commit

Permalink
Fix spurious error message in dev console
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gorhill committed Jul 31, 2021
1 parent dc08478 commit 2eb02c5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions platform/common/vapi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 2eb02c5

Please sign in to comment.