summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-08-20 18:30:22 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-08-20 18:30:22 +0200
commit0d4c78c2a133317d8fe6db85e604e128db9e686f (patch)
treecec8799219c97244ddeccc5798979ad2299d80cd
parentdca486d48f4fe375d84f1a64a6993f66bd1e82d8 (diff)
parentf02b9e8867f7ee1320a128ade0b2c2640788a96b (diff)
downloadmullvadvpn-0d4c78c2a133317d8fe6db85e604e128db9e686f.tar.xz
mullvadvpn-0d4c78c2a133317d8fe6db85e604e128db9e686f.zip
Merge branch 'grpc-cancel-workaround' into master
-rw-r--r--gui/src/main/daemon-rpc.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index ff755e2a36..4bbca29930 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -548,15 +548,6 @@ export class DaemonRpc {
});
call.on('error', (error) => {
- // if the subscription was cancelled by the client, there's no reason to
- // invoke the onError handler
- if (
- 'code' in error &&
- error['code'] === grpc.status.CANCELLED &&
- !this.subscriptions.has(subscriptionId)
- ) {
- return;
- }
listener.onError(error);
this.removeSubscription(subscriptionId);
});
@@ -573,7 +564,15 @@ export class DaemonRpc {
const subscription = this.subscriptions.get(id);
if (subscription !== undefined) {
this.subscriptions.delete(id);
- subscription.cancel();
+ subscription.removeAllListeners('data');
+ subscription.removeAllListeners('error');
+ try {
+ subscription.cancel();
+ } catch (error) {
+ if (error.code !== grpc.status.CANCELLED) {
+ throw error;
+ }
+ }
}
}