@smithy/fetch-http-handler 5.3.10 → 5.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-cjs/index.js CHANGED
@@ -54,8 +54,7 @@ class FetchHttpHandler {
54
54
  const keepAlive = this.config.keepAlive === true;
55
55
  const credentials = this.config.credentials;
56
56
  if (abortSignal?.aborted) {
57
- const abortError = new Error("Request aborted");
58
- abortError.name = "AbortError";
57
+ const abortError = buildAbortError(abortSignal);
59
58
  return Promise.reject(abortError);
60
59
  }
61
60
  let path = request.path;
@@ -130,8 +129,7 @@ class FetchHttpHandler {
130
129
  if (abortSignal) {
131
130
  raceOfPromises.push(new Promise((resolve, reject) => {
132
131
  const onAbort = () => {
133
- const abortError = new Error("Request aborted");
134
- abortError.name = "AbortError";
132
+ const abortError = buildAbortError(abortSignal);
135
133
  reject(abortError);
136
134
  };
137
135
  if (typeof abortSignal.addEventListener === "function") {
@@ -157,6 +155,22 @@ class FetchHttpHandler {
157
155
  return this.config ?? {};
158
156
  }
159
157
  }
158
+ function buildAbortError(abortSignal) {
159
+ const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal
160
+ ? abortSignal.reason
161
+ : undefined;
162
+ if (reason) {
163
+ if (reason instanceof Error) {
164
+ return reason;
165
+ }
166
+ const abortError = new Error(String(reason));
167
+ abortError.name = "AbortError";
168
+ return abortError;
169
+ }
170
+ const abortError = new Error("Request aborted");
171
+ abortError.name = "AbortError";
172
+ return abortError;
173
+ }
160
174
 
161
175
  const streamCollector = async (stream) => {
162
176
  if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
@@ -36,8 +36,7 @@ export class FetchHttpHandler {
36
36
  const keepAlive = this.config.keepAlive === true;
37
37
  const credentials = this.config.credentials;
38
38
  if (abortSignal?.aborted) {
39
- const abortError = new Error("Request aborted");
40
- abortError.name = "AbortError";
39
+ const abortError = buildAbortError(abortSignal);
41
40
  return Promise.reject(abortError);
42
41
  }
43
42
  let path = request.path;
@@ -112,8 +111,7 @@ export class FetchHttpHandler {
112
111
  if (abortSignal) {
113
112
  raceOfPromises.push(new Promise((resolve, reject) => {
114
113
  const onAbort = () => {
115
- const abortError = new Error("Request aborted");
116
- abortError.name = "AbortError";
114
+ const abortError = buildAbortError(abortSignal);
117
115
  reject(abortError);
118
116
  };
119
117
  if (typeof abortSignal.addEventListener === "function") {
@@ -139,3 +137,19 @@ export class FetchHttpHandler {
139
137
  return this.config ?? {};
140
138
  }
141
139
  }
140
+ function buildAbortError(abortSignal) {
141
+ const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal
142
+ ? abortSignal.reason
143
+ : undefined;
144
+ if (reason) {
145
+ if (reason instanceof Error) {
146
+ return reason;
147
+ }
148
+ const abortError = new Error(String(reason));
149
+ abortError.name = "AbortError";
150
+ return abortError;
151
+ }
152
+ const abortError = new Error("Request aborted");
153
+ abortError.name = "AbortError";
154
+ return abortError;
155
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/fetch-http-handler",
3
- "version": "5.3.10",
3
+ "version": "5.3.12",
4
4
  "description": "Provides a way to make requests",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
@@ -28,14 +28,14 @@
28
28
  "module": "./dist-es/index.js",
29
29
  "types": "./dist-types/index.d.ts",
30
30
  "dependencies": {
31
- "@smithy/protocol-http": "^5.3.9",
32
- "@smithy/querystring-builder": "^4.2.9",
33
- "@smithy/types": "^4.12.1",
31
+ "@smithy/protocol-http": "^5.3.10",
32
+ "@smithy/querystring-builder": "^4.2.10",
33
+ "@smithy/types": "^4.13.0",
34
34
  "@smithy/util-base64": "^4.3.1",
35
35
  "tslib": "^2.6.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@smithy/abort-controller": "^4.2.9",
38
+ "@smithy/abort-controller": "^4.2.10",
39
39
  "concurrently": "7.0.0",
40
40
  "downlevel-dts": "0.10.1",
41
41
  "premove": "4.0.0",