Use abort-controller package to fix typing issues (#6077)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-08-22 11:18:01 -04:00
1 parent e7d9614700
commit 436aa3dcda
9 files changed
+25 -8

No files matched your search

@@ -14,6 +14,7 @@ import { DeploymentApi, Ingress, IngressApi, Pod, PodApi } from "../endpoints";
import { getDiForUnitTesting } from "../../../renderer/getDiForUnitTesting";
import apiManagerInjectable from "../api-manager/manager.injectable";
import autoRegistrationInjectable from "../api-manager/auto-registration.injectable";
import { AbortController } from "abort-controller";
jest.mock("../api-manager");
+2 -4
View File
@@ -27,9 +27,7 @@ import type { PartialDeep } from "type-fest";
import logger from "../logger";
import { Environments, getEnvironmentSpecificLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import autoRegistrationEmitterInjectable from "./api-manager/auto-registration-emitter.injectable";
// TODO: upgrade node-fetch once we are starting to use ES modules
type LegacyAbortSignal = NonNullable<RequestInit["signal"]>;
import type AbortController from "abort-controller";
/**
* The options used for creating a `KubeApi`
@@ -719,7 +717,7 @@ export class KubeApi<
const requestParams = timeout ? { query: { timeoutSeconds: timeout }} : {};
const watchUrl = this.getWatchUrl(namespace);
const responsePromise = this.request.getResponse(watchUrl, requestParams, {
signal: abortController.signal as LegacyAbortSignal,
signal: abortController.signal,
timeout: 600_000,
});
+2 -4
View File
@@ -20,9 +20,7 @@ import logger from "../logger";
import assert from "assert";
import type { PartialDeep } from "type-fest";
import { entries } from "../utils/objects";
// TODO: upgrade node-fetch once we are starting to use ES modules
type LegacyAbortSignal = NonNullable<RequestInit["signal"]>;
import { AbortController } from "abort-controller";
export type OnLoadFailure = (error: unknown) => void;
@@ -480,7 +478,7 @@ export abstract class KubeObjectStore<
});
// TODO: upgrade node-fetch once we are starting to use ES modules
const signal = abortController.signal as LegacyAbortSignal;
const signal = abortController.signal;
const callback: KubeApiWatchCallback<D> = (data, error) => {
if (!this.isLoaded || error?.type === "aborted") return;
+2
View File
@@ -3,6 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { AbortController } from "abort-controller";
/**
* This is like an `AbortController` but will also abort if the parent aborts,
* but won't make the parent abort if this aborts (single direction)
+2
View File
@@ -3,6 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type AbortController from "abort-controller";
/**
* Return a promise that will be resolved after at least `timeout` ms have
* passed. If `failFast` is provided then the promise is also resolved if it has
+2
View File
@@ -3,6 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { AbortSignal } from "abort-controller";
/**
* Creates a new promise that will be rejected when the signal rejects.
*
@@ -10,6 +10,7 @@ import type { ClusterFrameContext } from "../cluster-frame-context/cluster-frame
import logger from "../../common/logger";
import type { KubeObjectStoreLoadAllParams, KubeObjectStoreSubscribeParams } from "../../common/k8s-api/kube-object.store";
import type { RequestInit } from "node-fetch";
import { AbortController } from "abort-controller";
// TODO: upgrade node-fetch once we are starting to use ES modules
type LegacyAbortSignal = NonNullable<RequestInit["signal"]>;