@smithy/node-http-handler
Advanced tools
| export function buildAbortError(abortSignal) { | ||
| const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal | ||
| ? abortSignal.reason | ||
| : undefined; | ||
| if (reason) { | ||
| if (reason instanceof Error) { | ||
| return reason; | ||
| } | ||
| const abortError = new Error(String(reason)); | ||
| abortError.name = "AbortError"; | ||
| return abortError; | ||
| } | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| return abortError; | ||
| } |
| /** | ||
| * Builds an abort error, using the AbortSignal's reason if available. | ||
| * | ||
| * @param abortSignal - Optional AbortSignal that may contain a reason. | ||
| * @returns An Error with name "AbortError". If the signal has a reason that's | ||
| * already an Error, returns it directly. Otherwise creates a new Error | ||
| * with the reason as the message, or "Request aborted" if no reason. | ||
| */ | ||
| export declare function buildAbortError(abortSignal?: unknown): Error; |
| /** | ||
| * Builds an abort error, using the AbortSignal's reason if available. | ||
| * | ||
| * @param abortSignal - Optional AbortSignal that may contain a reason. | ||
| * @returns An Error with name "AbortError". If the signal has a reason that's | ||
| * already an Error, returns it directly. Otherwise creates a new Error | ||
| * with the reason as the message, or "Request aborted" if no reason. | ||
| */ | ||
| export declare function buildAbortError(abortSignal?: unknown): Error; |
+21
-8
@@ -10,2 +10,19 @@ 'use strict'; | ||
| function buildAbortError(abortSignal) { | ||
| const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal | ||
| ? abortSignal.reason | ||
| : undefined; | ||
| if (reason) { | ||
| if (reason instanceof Error) { | ||
| return reason; | ||
| } | ||
| const abortError = new Error(String(reason)); | ||
| abortError.name = "AbortError"; | ||
| return abortError; | ||
| } | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| return abortError; | ||
| } | ||
| const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"]; | ||
@@ -291,4 +308,3 @@ | ||
| if (abortSignal?.aborted) { | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -361,4 +377,3 @@ return; | ||
| req.destroy(); | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -576,4 +591,3 @@ }; | ||
| fulfilled = true; | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -640,4 +654,3 @@ return; | ||
| req.close(); | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| rejectWithDestroy(abortError); | ||
@@ -644,0 +657,0 @@ }; |
@@ -5,2 +5,3 @@ import { HttpResponse } from "@smithy/protocol-http"; | ||
| import { Agent as hsAgent, request as hsRequest } from "https"; | ||
| import { buildAbortError } from "./build-abort-error"; | ||
| import { NODEJS_TIMEOUT_ERROR_CODES } from "./constants"; | ||
@@ -114,4 +115,3 @@ import { getTransformedHeaders } from "./get-transformed-headers"; | ||
| if (abortSignal?.aborted) { | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -184,4 +184,3 @@ return; | ||
| req.destroy(); | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -188,0 +187,0 @@ }; |
| import { HttpResponse } from "@smithy/protocol-http"; | ||
| import { buildQueryString } from "@smithy/querystring-builder"; | ||
| import { constants } from "http2"; | ||
| import { buildAbortError } from "./build-abort-error"; | ||
| import { getTransformedHeaders } from "./get-transformed-headers"; | ||
@@ -58,4 +59,3 @@ import { NodeHttp2ConnectionManager } from "./node-http2-connection-manager"; | ||
| fulfilled = true; | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| reject(abortError); | ||
@@ -122,4 +122,3 @@ return; | ||
| req.close(); | ||
| const abortError = new Error("Request aborted"); | ||
| abortError.name = "AbortError"; | ||
| const abortError = buildAbortError(abortSignal); | ||
| rejectWithDestroy(abortError); | ||
@@ -126,0 +125,0 @@ }; |
+1
-1
| { | ||
| "name": "@smithy/node-http-handler", | ||
| "version": "4.4.12", | ||
| "version": "4.4.13", | ||
| "description": "Provides a way to make requests", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
99410
1.73%61
5.17%2125
2.11%