From d93ce0073688531efa5f4c5562452212b7c5370a Mon Sep 17 00:00:00 2001 From: Lukas Kurucz Date: Mon, 25 Apr 2022 04:53:16 -0700 Subject: [PATCH] fix: clear reconnect timeout on stop() (#3646) Summary: When using `flipperClient.stop()`, after `flipperClient.start()`, it's impossible to `start` new connection, since the previous instance would keep active `reconnect`, so would override the previous connection. ## Changelog - clean reconnect timer when calling `flipperClient.stop()` Pull Request resolved: https://github.com/facebook/flipper/pull/3646 Test Plan: 1. `flipperClient.start('Demo app', { urlBase: 'null:8333' });` - this will fail connection, but keep retrying 2. `flipperClient.stop()` - should disconnect from WS and clear all reconnect timers 3. `flipperClient.start('Demo app', { urlBase: 'localhost:8333' });` - should connect succefully Reviewed By: antonk52 Differential Revision: D35810547 Pulled By: lblasa fbshipit-source-id: 6f0b04df890c1519abb72895157785b01d35b5f2 --- js/js-flipper/src/client.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/js-flipper/src/client.ts b/js/js-flipper/src/client.ts index 9fc305802..3bdc46d33 100644 --- a/js/js-flipper/src/client.ts +++ b/js/js-flipper/src/client.ts @@ -190,6 +190,11 @@ export class FlipperClient { } stop() { + if (this.reconnectionTimer) { + clearTimeout(this.reconnectionTimer); + this.reconnectionTimer = undefined; + } + if (!this.ws) { return; }