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
This commit is contained in:
Lukas Kurucz
2022-04-25 04:53:16 -07:00
committed by Facebook GitHub Bot
parent bf988659cf
commit d93ce00736

View File

@@ -190,6 +190,11 @@ export class FlipperClient {
} }
stop() { stop() {
if (this.reconnectionTimer) {
clearTimeout(this.reconnectionTimer);
this.reconnectionTimer = undefined;
}
if (!this.ws) { if (!this.ws) {
return; return;
} }