mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove direct dependency on 'abort-controller' package (#7366)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
d7b2202c1f
commit
37513dee29
12 files changed
+5
-17
No files matched your search
@@ -3,13 +3,15 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { formatDuration } from "@k8slens/utilities";
|
||||
|
||||
/**
|
||||
* Creates an AbortController with an associated timeout
|
||||
* @param timeout The number of milliseconds before this controller will auto abort
|
||||
*/
|
||||
export function withTimeout(timeout: number): AbortController {
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
const id = setTimeout(() => controller.abort(`Operation timed out: timeout ${formatDuration(timeout)}`), timeout);
|
||||
|
||||
controller.signal.addEventListener("abort", () => clearTimeout(id));
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import { flushPromises } from "@k8slens/test-utils";
|
||||
import createKubeJsonApiInjectable from "../create-kube-json-api.injectable";
|
||||
import type { IKubeWatchEvent } from "../kube-watch-event";
|
||||
import type { KubeJsonApiDataFor } from "../kube-object";
|
||||
import AbortController from "abort-controller";
|
||||
import setupAutoRegistrationInjectable from "../../../renderer/before-frame-starts/runnables/setup-auto-registration.injectable";
|
||||
import { createMockResponseFromStream, createMockResponseFromString } from "../../../test-utils/mock-responses";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../../renderer/stores-apis-can-be-created.injectable";
|
||||
|
||||
@@ -20,7 +20,6 @@ import type { Patch } from "rfc6902";
|
||||
import assert from "assert";
|
||||
import type { PartialDeep } from "type-fest";
|
||||
import type { Logger } from "../logger";
|
||||
import type AbortController from "abort-controller";
|
||||
import { matches } from "lodash/fp";
|
||||
import { makeObservable, observable } from "mobx";
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import type { Patch } from "rfc6902";
|
||||
import type { Logger } from "../logger";
|
||||
import assert from "assert";
|
||||
import type { PartialDeep } from "type-fest";
|
||||
import AbortController from "abort-controller";
|
||||
import type { ClusterContext } from "../../renderer/cluster-frame-context/cluster-frame-context";
|
||||
import autoBind from "auto-bind";
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ const k8sRequestInjectable = getInjectable({
|
||||
) => {
|
||||
const controller = timeout ? withTimeout(timeout) : undefined;
|
||||
|
||||
if (controller) {
|
||||
signal?.addEventListener("abort", () => controller.abort());
|
||||
if (controller && signal) {
|
||||
signal.addEventListener("abort", () => controller.abort());
|
||||
}
|
||||
|
||||
const response = await lensFetch(`/${cluster.id}${pathnameAndQuery}`, {
|
||||
|
||||
@@ -8,7 +8,6 @@ import { disposer, getOrInsert, noop, WrappedAbortController } from "@k8slens/ut
|
||||
import { once } from "lodash";
|
||||
import type { Logger } from "../../common/logger";
|
||||
import type { KubeObjectStoreLoadAllParams, KubeObjectStoreSubscribeParams } from "../../common/k8s-api/kube-object.store";
|
||||
import AbortController from "abort-controller";
|
||||
import type { ClusterContext } from "../cluster-frame-context/cluster-frame-context";
|
||||
|
||||
// Kubernetes watch-api client
|
||||
|
||||
Reference in new issue
Block a user