Skip to content

Commit f3d9d4f

Browse files
committed
only one reconnect timeout
1 parent e403df4 commit f3d9d4f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/vscode/src/controller.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class NotebookController {
6262
private _port: undefined | number;
6363
private _process: undefined | ChildProcess;
6464
private _websocket: undefined | WebSocket;
65+
private _timeout: undefined | NodeJS.Timeout;
6566
private _client: undefined | Client;
6667
private _clientWaiters: {
6768
resolve: (client: Client) => void;
@@ -185,11 +186,14 @@ export class NotebookController {
185186
return;
186187
}
187188
log.info(`ws close`);
188-
setTimeout(() => {
189-
if (this._state === "connecting" || this._state === "connected") {
190-
this.run("started");
191-
}
192-
}, RECONNECT_INTERVAL);
189+
if (!this._timeout) {
190+
this._timeout = setTimeout(() => {
191+
this._timeout = undefined;
192+
if (this._state === "connecting" || this._state === "connected") {
193+
this.run("started");
194+
}
195+
}, RECONNECT_INTERVAL);
196+
}
193197
});
194198
}
195199

0 commit comments

Comments
 (0)