remove usages of node-abort-controller

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-11-28 17:04:49 +01:00
parent e948f5528a
commit de8a975911
26 changed files with 43 additions and 48 deletions
+5 -7
View File
@@ -6,8 +6,6 @@
/// <reference types="node" />
/// <reference types="webpack-env" />
import { AbortController as AbortController_2 } from 'node-abort-controller';
import { AbortSignal as AbortSignal_2 } from 'node-abort-controller';
import aws from 'aws-sdk';
import { AwsS3Integration } from '@backstage/integration';
import { AzureIntegration } from '@backstage/integration';
@@ -200,7 +198,7 @@ export interface ContainerRunner {
// @alpha
export interface Context {
readonly abortSignal: AbortSignal_2;
readonly abortSignal: AbortSignal;
readonly deadline: Date | undefined;
value<T = unknown>(key: string): T | undefined;
}
@@ -210,7 +208,7 @@ export class Contexts {
static root(): Context;
static withAbort(
parentCtx: Context,
source: AbortController_2 | AbortSignal_2,
source: AbortController | AbortSignal,
): Context;
static withTimeoutDuration(parentCtx: Context, timeout: Duration): Context;
static withTimeoutMillis(parentCtx: Context, timeout: number): Context;
@@ -544,7 +542,7 @@ export type ReadTreeOptions = {
},
): boolean;
etag?: string;
signal?: AbortSignal_2;
signal?: AbortSignal;
};
// @public
@@ -598,7 +596,7 @@ export type ReadTreeResponseFile = {
// @public
export type ReadUrlOptions = {
etag?: string;
signal?: AbortSignal_2;
signal?: AbortSignal;
};
// @public
@@ -657,7 +655,7 @@ export type RunContainerOptions = {
// @public
export type SearchOptions = {
etag?: string;
signal?: AbortSignal_2;
signal?: AbortSignal;
};
// @public
-1
View File
@@ -73,7 +73,6 @@
"minimatch": "^5.0.0",
"minimist": "^1.2.5",
"morgan": "^1.10.0",
"node-abort-controller": "^3.0.1",
"node-fetch": "^2.6.7",
"node-forge": "^1.3.1",
"raw-body": "^2.4.1",
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { AbortController } from 'node-abort-controller';
import { AbortContext } from './AbortContext';
import { RootContext } from './RootContext';
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { AbortController, AbortSignal } from 'node-abort-controller';
import { Context } from './types';
/**
@@ -15,7 +15,6 @@
*/
import { Duration } from 'luxon';
import { AbortController } from 'node-abort-controller';
import { Contexts } from './Contexts';
describe('Contexts', () => {
@@ -15,7 +15,6 @@
*/
import { Duration } from 'luxon';
import { AbortController, AbortSignal } from 'node-abort-controller';
import { AbortContext } from './AbortContext';
import { RootContext } from './RootContext';
import { Context } from './types';
@@ -14,29 +14,36 @@
* limitations under the License.
*/
import { AbortSignal } from 'node-abort-controller';
import { Context } from './types';
/**
* Since the root context can never abort, and since nobody is every meant to
* dispatch events through it, we can use a static dummy instance for
* Since the root context can never abort, and since nobody is ever meant to
* dispatch events through it, we can use a static fake instance for
* efficiency.
*/
const dummyAbortSignal: AbortSignal = Object.freeze({
aborted: false,
addEventListener() {},
removeEventListener() {},
dispatchEvent() {
return true;
},
onabort: null,
});
const fakeAbortController = new AbortController();
const fakeAbortSignal: AbortSignal = Object.freeze(
Object.assign(
{
aborted: false,
reason: undefined,
throwIfAborted() {},
onabort() {},
addEventListener() {},
removeEventListener() {},
dispatchEvent() {
return true;
},
},
fakeAbortController.signal,
),
);
/**
* An empty root context.
*/
export class RootContext implements Context {
readonly abortSignal = dummyAbortSignal;
readonly abortSignal = fakeAbortSignal;
readonly deadline = undefined;
value<T = unknown>(_key: string): T | undefined {
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { AbortSignal } from 'node-abort-controller';
import { Context } from './types';
/**
@@ -14,8 +14,6 @@
* limitations under the License.
*/
import { AbortSignal } from 'node-abort-controller';
/**
* A context that is meant to be passed as a ctx variable down the call chain,
* to pass along scoped information and abort signals.
@@ -17,7 +17,6 @@
import { Readable } from 'stream';
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import { AbortSignal } from 'node-abort-controller';
/**
* A generic interface for fetching plain data from URLs.