Skip to content

Commit e030d53

Browse files
authored
refactor: Remove abort controller dependency (#2680)
* refactor: Remove abort-controller dependency * test refactor
1 parent f2ab4ae commit e030d53

3 files changed

Lines changed: 4 additions & 16 deletions

File tree

handwritten/storage/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
"dependencies": {
7575
"@google-cloud/paginator": "^6.0.0",
7676
"@google-cloud/promisify": "^5.0.0",
77-
"abort-controller": "^3.0.0",
7877
"async-retry": "^1.3.3",
7978
"duplexify": "^4.1.3",
8079
"fast-xml-parser": "^5.2.0",

handwritten/storage/src/resumable-upload.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import AbortController from 'abort-controller';
1615
import {createHash} from 'crypto';
1716
import {
1817
GaxiosOptions,

handwritten/storage/test/resumable-upload.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ import {getDirName} from '../src/util.js';
4545

4646
nock.disableNetConnect();
4747

48-
class AbortController {
49-
aborted = false;
50-
signal = this;
51-
abort() {
52-
this.aborted = true;
53-
}
54-
}
55-
5648
const RESUMABLE_INCOMPLETE_STATUS_CODE = 308;
5749
/** 256 KiB */
5850
const CHUNK_SIZE_MULTIPLE = 2 ** 18;
@@ -99,7 +91,6 @@ describe('resumable-upload', () => {
9991
const keyFile = path.join(getDirName(), '../../../test/fixtures/keys.json');
10092

10193
before(() => {
102-
mockery.registerMock('abort-controller', AbortController);
10394
mockery.enable({useCleanCache: true, warnOnUnregistered: false});
10495
upload = require('../src/resumable-upload').upload;
10596
});
@@ -1807,7 +1798,7 @@ describe('resumable-upload', () => {
18071798
it('should pass a signal from the abort controller', done => {
18081799
up.authClient = {
18091800
request: (reqOpts: GaxiosOptions) => {
1810-
assert(reqOpts.signal instanceof AbortController);
1801+
assert(reqOpts.signal instanceof AbortSignal);
18111802
done();
18121803
},
18131804
};
@@ -1817,19 +1808,18 @@ describe('resumable-upload', () => {
18171808
it('should abort on an error', done => {
18181809
up.on('error', () => {});
18191810

1820-
let abortController: AbortController;
1811+
let abortSignal: AbortSignal;
18211812
up.authClient = {
18221813
request: (reqOpts: GaxiosOptions) => {
1823-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1824-
abortController = reqOpts.signal as any;
1814+
abortSignal = reqOpts.signal as AbortSignal;
18251815
},
18261816
};
18271817

18281818
up.makeRequestStream(REQ_OPTS);
18291819
up.emit('error', new Error('Error.'));
18301820

18311821
setImmediate(() => {
1832-
assert.strictEqual(abortController.aborted, true);
1822+
assert.strictEqual(abortSignal.aborted, true);
18331823
done();
18341824
});
18351825
});

0 commit comments

Comments
 (0)