summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-08-20 17:42:02 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-08-20 17:58:36 +0200
commitf02b9e8867f7ee1320a128ade0b2c2640788a96b (patch)
treecec8799219c97244ddeccc5798979ad2299d80cd /gui/src
parentdca486d48f4fe375d84f1a64a6993f66bd1e82d8 (diff)
downloadmullvadvpn-f02b9e8867f7ee1320a128ade0b2c2640788a96b.tar.xz
mullvadvpn-f02b9e8867f7ee1320a128ade0b2c2640788a96b.zip
Fix error caused by calling cancel on open gRPC stream
Diffstat (limited to 'gui/src')
-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;
+ }
+ }
}
}