1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Ensure port instance exists when waiting for connection requests

This commit is contained in:
Raymond Hill 2020-09-01 09:53:35 -04:00
parent 90743532f1
commit 9ab631b4c4
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -151,8 +151,9 @@ vAPI.MessagingConnection = class {
static addListener(listener) { static addListener(listener) {
listeners.add(listener); listeners.add(listener);
vAPI.messaging.getPort(); // Ensure a port instance exists
} }
static async connectTo(from, to, handler) { static connectTo(from, to, handler) {
const port = vAPI.messaging.getPort(); const port = vAPI.messaging.getPort();
if ( port === null ) { return; } if ( port === null ) { return; }
const connection = new vAPI.MessagingConnection(handler, { const connection = new vAPI.MessagingConnection(handler, {