mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
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) {
|
proxy(response) {
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/383
|
// https://github.com/chrisaljoudi/uBlock/issues/383
|
||||||
if ( this.messaging.ports.has(this.port.name) ) {
|
try {
|
||||||
this.port.postMessage({
|
this.port.postMessage({
|
||||||
msgId: this.msgId,
|
msgId: this.msgId,
|
||||||
msg: response !== undefined ? response : null,
|
msg: response !== undefined ? response : null,
|
||||||
});
|
});
|
||||||
|
} catch (ex) {
|
||||||
|
this.messaging.onPortDisconnect(this.port);
|
||||||
}
|
}
|
||||||
// Store for reuse
|
// Store for reuse
|
||||||
this.port = null;
|
this.port = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user