1
0
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:
Sebastian Malton 2021-11-03 13:16:31 -04:00
parent a08fe81a7b
commit 3c5265848c

View File

@ -71,13 +71,15 @@ 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(
// cluster.disconnect is set to `false` when the cluster starts to connect
() => !cluster.disconnected,
() => {
when( when(
() => { () => {
const cluster = ClusterStore.getInstance().getById(clusterId); const cluster = ClusterStore.getInstance().getById(clusterId);
@ -87,8 +89,10 @@ export class ClusterFrameHandler extends Singleton {
() => { () => {
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();
},
);
}, },
); );
} }