mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
review fixes
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
45aa08d396
commit
e7943ce05f
@ -381,9 +381,7 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
|
||||
responsePromise.then((response) => {
|
||||
if (!response.ok && !abortController.signal.aborted) {
|
||||
if (callback) {
|
||||
callback(null, response);
|
||||
}
|
||||
callback?.(null, response);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -424,19 +422,13 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
}, (error) => {
|
||||
if (error instanceof DOMException) return; // AbortController rejects, we can ignore it
|
||||
|
||||
if (callback) {
|
||||
callback(null, error);
|
||||
}
|
||||
callback?.(null, error);
|
||||
}).catch((error) => {
|
||||
if (callback) {
|
||||
callback(null, error);
|
||||
}
|
||||
callback?.(null, error);
|
||||
});
|
||||
|
||||
const disposer = () => {
|
||||
if (!abortController.signal.aborted) {
|
||||
abortController.abort();
|
||||
}
|
||||
abortController.abort();
|
||||
};
|
||||
|
||||
return disposer;
|
||||
|
||||
@ -48,8 +48,8 @@ export interface IKubeStatus {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export class KubeStatus implements IKubeStatus {
|
||||
public readonly kind: string;
|
||||
export class KubeStatus {
|
||||
public readonly kind = "Status";
|
||||
public readonly apiVersion: string;
|
||||
public readonly code: number;
|
||||
public readonly message: string;
|
||||
|
||||
@ -288,6 +288,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
||||
}
|
||||
|
||||
private watchNamespace(api: KubeApi<T>, namespace: string, abortController: AbortController) {
|
||||
let timedRetry: NodeJS.Timeout;
|
||||
|
||||
abortController.signal.addEventListener("abort", () => clearTimeout(timedRetry));
|
||||
|
||||
const callback = (data: IKubeWatchEvent, error: any) => {
|
||||
if (!this.isLoaded || abortController.signal.aborted) return;
|
||||
@ -297,9 +300,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
||||
// api has gone, let's not retry
|
||||
return;
|
||||
} else { // not sure what to do, best to retry
|
||||
setTimeout(() => {
|
||||
if (abortController.signal.aborted) return;
|
||||
|
||||
timedRetry = setTimeout(() => {
|
||||
api.watch({
|
||||
namespace,
|
||||
abortController,
|
||||
@ -309,9 +310,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
||||
}
|
||||
} else if (error instanceof KubeStatus && error.code === 410) {
|
||||
// resourceVersion has gone, let's try to reload
|
||||
setTimeout(() => {
|
||||
if (abortController.signal.aborted) return;
|
||||
|
||||
timedRetry = setTimeout(() => {
|
||||
(namespace === "" ? this.loadAll({ merge: false }) : this.loadAll({namespaces: [namespace]})).then(() => {
|
||||
api.watch({
|
||||
namespace,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user