diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-04-29 13:07:02 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-04-29 13:07:02 +0200 |
| commit | f173d8cc7039c71f0e5306ff88b019d69cf02b1f (patch) | |
| tree | e615ee1f571c1a145e3149f879c1c1ce90603374 | |
| parent | 0454d1634b85d818346b097fdcf1311ec24b1a4f (diff) | |
| parent | 145949569df4a78b7ca8efe48459c5560c3fb0ce (diff) | |
| download | mullvadvpn-f173d8cc7039c71f0e5306ff88b019d69cf02b1f.tar.xz mullvadvpn-f173d8cc7039c71f0e5306ff88b019d69cf02b1f.zip | |
Merge branch 'fix-duplicate-daemon-clients'
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index ba913fea87..10e39f020d 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -176,7 +176,13 @@ export class DaemonRpc { public connect(): Promise<void> { return new Promise((resolve, reject) => { + const usedClient = this.client; this.client.waitForReady(this.deadlineFromNow(), (error) => { + if (this.client !== usedClient) { + reject(new Error('Stale connection attempt')); + return; + } + if (error) { this.onClose(error); this.ensureConnectivity(); @@ -831,6 +837,9 @@ export class DaemonRpc { // check the connectivity state and nudge the client into connecting. // `grpc.Channel.getConnectivityState(true)` should make it attempt to connect. private ensureConnectivity() { + if (this.reconnectionTimeout) { + clearTimeout(this.reconnectionTimeout); + } this.reconnectionTimeout = setTimeout(() => { const lastState = this.client.getChannel().getConnectivityState(true); if (this.channelDisconnected(lastState)) { |
