Skip to content

Commit 4e5f461

Browse files
authored
[abort-controller] Remove polyfills for AbortController and AbortSignal (Azure#27921)
### Packages impacted by this PR `@azure/abort-controller` ### Issues associated with this PR Fixes Azure#27018 ### Describe the problem that is addressed by this PR As `AbortController` and `AbortSignal` now exist in all supported runtimes, we do not need to have our own userland implementation of them. This PR creates a new major version of the `abort-controller` package that only has `AbortSignalLike` and `AbortError` and updates core + test-utils to use the new version.
1 parent 86c7a3c commit 4e5f461

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+722
-1083
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 608 additions & 333 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/core/abort-controller/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Release History
22

3-
## 1.1.1 (Unreleased)
3+
## 2.0.0 (Unreleased)
44

55
### Features Added
66

77
### Breaking Changes
88

9+
- Removed our polyfill implementation for `AbortSignal` and `AbortController` as these are now supported across our minimum required runtime environments.
10+
911
### Bugs Fixed
1012

1113
### Other Changes

sdk/core/abort-controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@azure/abort-controller",
33
"sdk-type": "client",
4-
"version": "1.1.1",
4+
"version": "2.0.0",
55
"description": "Microsoft Azure SDK for JavaScript - Aborter",
66
"main": "./dist/index.js",
77
"module": "dist-esm/src/index.js",

sdk/core/abort-controller/review/abort-controller.api.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,11 @@
44
55
```ts
66

7-
// @public
8-
class AbortController_2 {
9-
constructor(parentSignals?: AbortSignalLike[]);
10-
constructor(...parentSignals: AbortSignalLike[]);
11-
abort(): void;
12-
get signal(): AbortSignal_2;
13-
static timeout(ms: number): AbortSignal_2;
14-
}
15-
export { AbortController_2 as AbortController }
16-
177
// @public
188
export class AbortError extends Error {
199
constructor(message?: string);
2010
}
2111

22-
// @public
23-
class AbortSignal_2 implements AbortSignalLike {
24-
constructor();
25-
get aborted(): boolean;
26-
addEventListener(_type: "abort", listener: (this: AbortSignalLike, ev: any) => any): void;
27-
dispatchEvent(_event: Event): boolean;
28-
static get none(): AbortSignal_2;
29-
onabort: ((ev?: Event) => any) | null;
30-
removeEventListener(_type: "abort", listener: (this: AbortSignalLike, ev: any) => any): void;
31-
}
32-
export { AbortSignal_2 as AbortSignal }
33-
3412
// @public
3513
export interface AbortSignalLike {
3614
readonly aborted: boolean;

sdk/core/abort-controller/src/AbortController.ts

Lines changed: 0 additions & 133 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* This error is thrown when an asynchronous operation has been aborted.
6+
* Check for this error by testing the `name` that the name property of the
7+
* error matches `"AbortError"`.
8+
*
9+
* @example
10+
* ```ts
11+
* const controller = new AbortController();
12+
* controller.abort();
13+
* try {
14+
* doAsyncWork(controller.signal)
15+
* } catch (e) {
16+
* if (e.name === 'AbortError') {
17+
* // handle abort error here.
18+
* }
19+
* }
20+
* ```
21+
*/
22+
export class AbortError extends Error {
23+
constructor(message?: string) {
24+
super(message);
25+
this.name = "AbortError";
26+
}
27+
}

sdk/core/abort-controller/src/AbortSignal.ts

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)