mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix WHEN_TIMEOUT
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a08fe81a7b
commit
3c5265848c
@ -71,24 +71,28 @@ export class ClusterFrameHandler extends Singleton {
|
|||||||
|
|
||||||
logger.info(`[LENS-VIEW]: waiting cluster to be ready, clusterId=${clusterId}`);
|
logger.info(`[LENS-VIEW]: waiting cluster to be ready, clusterId=${clusterId}`);
|
||||||
|
|
||||||
// we cannot wait forever because cleanup would be blocked for broken cluster connections
|
const dispose = when(
|
||||||
when(() => cluster.ready, { timeout: 5_000 })
|
() => cluster.ready,
|
||||||
.then(() => logger.info(`[LENS-VIEW]: cluster is ready, clusterId=${clusterId}`))
|
() => logger.info(`[LENS-VIEW]: cluster is ready, clusterId=${clusterId}`),
|
||||||
.finally(() => this.autoCleanOnRemove(clusterId, iframe));
|
);
|
||||||
}
|
|
||||||
|
|
||||||
private autoCleanOnRemove(clusterId: ClusterId, iframe: HTMLIFrameElement) {
|
|
||||||
when(
|
when(
|
||||||
|
// cluster.disconnect is set to `false` when the cluster starts to connect
|
||||||
|
() => !cluster.disconnected,
|
||||||
() => {
|
() => {
|
||||||
const cluster = ClusterStore.getInstance().getById(clusterId);
|
when(
|
||||||
|
() => {
|
||||||
|
const cluster = ClusterStore.getInstance().getById(clusterId);
|
||||||
|
|
||||||
return !cluster || (cluster.disconnected && this.views.get(clusterId)?.isLoaded);
|
return !cluster || (cluster.disconnected && this.views.get(clusterId)?.isLoaded);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
||||||
this.views.delete(clusterId);
|
this.views.delete(clusterId);
|
||||||
|
iframe.parentNode.removeChild(iframe);
|
||||||
iframe.parentNode.removeChild(iframe);
|
dispose();
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user