Skip to content

Commit

Permalink
Ignore connection status listener notification in constructor
Browse files Browse the repository at this point in the history
The TSP client implementation notifies clients when the method
addConnectionStatusListener() is called. This can lead to incorrect
state in on client side.

Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
bhufmann committed Apr 10, 2024
1 parent 77bf4f0 commit ab0fa48
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vscode-trace-common/src/client/tsp-client-provider-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ export class TspClientProvider implements ITspClientProvider {
private _traceManager: TraceManager;
private _experimentManager: ExperimentManager;
private _listeners: ((tspClient: TspClient) => void)[] = [];
private _initialized = false;

constructor(
private _url: string,
private _signalHandler: VsCodeMessageManager | undefined
) {
this.updateClients();
RestClient.addConnectionStatusListener(status => this._signalHandler?.notifyConnection(status));

RestClient.addConnectionStatusListener(status => {
// Ignore the first update that is sent when calling addConnectionStatusListener
if (this._initialized) {
this._signalHandler?.notifyConnection(status);
}
});
this._initialized = true;
this._tspClient.checkHealth(); // When this is called in the remote use-case, it will block the port-forwarding service-worker.
}

Expand Down

0 comments on commit ab0fa48

Please sign in to comment.