mirror of https://github.com/gorhill/uBlock.git
Better deal with no-longer-existing ports
Disconnected ports could still happen Even when the port was still seen as valid internally. Using a try-catch block makes invalid port detection more reliable. This is an occurrence I often encountered when stepping into content script code, causing suprious error messages to be thrown into uBO's background dev console.
This commit is contained in:
parent
efca367694
commit
c9710ac9d1
|
@ -1086,11 +1086,13 @@ vAPI.messaging = {
|
|||
}
|
||||
proxy(response) {
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/383
|
||||
if ( this.messaging.ports.has(this.port.name) ) {
|
||||
try {
|
||||
this.port.postMessage({
|
||||
msgId: this.msgId,
|
||||
msg: response !== undefined ? response : null,
|
||||
});
|
||||
} catch (ex) {
|
||||
this.messaging.onPortDisconnect(this.port);
|
||||
}
|
||||
// Store for reuse
|
||||
this.port = null;
|
||||
|
|
Loading…
Reference in New Issue