diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-09-21 11:07:18 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-09-21 15:34:17 +0200 |
| commit | ab348bb1f77da0b3ad66ba9789f918436b10b0a0 (patch) | |
| tree | 1d93c067e410cf84002a3952628fe119e1089e9e | |
| parent | 2ab32b1131b1b0b62dbc65eb5ae53a93e41ab73f (diff) | |
| download | mullvadvpn-ab348bb1f77da0b3ad66ba9789f918436b10b0a0.tar.xz mullvadvpn-ab348bb1f77da0b3ad66ba9789f918436b10b0a0.zip | |
Update error handling for newer gRPC version
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 0619e873ca..89360fbc15 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -155,7 +155,11 @@ export class DaemonRpc { public disconnect() { this.isConnected = false; - this.subscriptions.clear(); + + for (const subscriptionId of this.subscriptions.keys()) { + this.removeSubscription(subscriptionId); + } + this.client.close(); if (this.reconnectionTimeout) { clearTimeout(this.reconnectionTimeout); @@ -558,14 +562,14 @@ export class DaemonRpc { this.subscriptions.delete(id); subscription.removeAllListeners('data'); subscription.removeAllListeners('error'); - try { - subscription.cancel(); - } catch (e) { + + subscription.on('error', (e) => { const error = e as grpc.ServiceError; if (error.code !== grpc.status.CANCELLED) { throw error; } - } + }); + subscription.cancel(); } } |
