mirror of https://github.com/gorhill/uBlock.git
Handle possible exceptions in vAPI.messaging.broadcast()
I had exceptions thrown by that code once in a while, about the `port` object not being connected; possibly occurs only when using dev tools with breakpoints in uBO's code. Even if this can be reproduced randomly only when debugging uBO, it costs nothing to add code in there to handle exceptions.
This commit is contained in:
parent
32b04fa262
commit
eed13194fb
|
@ -1021,12 +1021,13 @@ vAPI.messaging.setup = function(defaultHandler) {
|
|||
/******************************************************************************/
|
||||
|
||||
vAPI.messaging.broadcast = function(message) {
|
||||
var messageWrapper = {
|
||||
broadcast: true,
|
||||
msg: message
|
||||
};
|
||||
for ( var port of this.ports.values() ) {
|
||||
port.postMessage(messageWrapper);
|
||||
const messageWrapper = { broadcast: true, msg: message };
|
||||
for ( const port of this.ports.values() ) {
|
||||
try {
|
||||
port.postMessage(messageWrapper);
|
||||
} catch(ex) {
|
||||
this.ports.delete(port.name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue