Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@smithy/node-http-handler

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/node-http-handler - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

51

dist-cjs/index.js

@@ -185,6 +185,8 @@ var __create = Object.create;

* @param agent - http(s) agent in use by the NodeHttpHandler instance.
* @param socketWarningTimestamp - last socket usage check timestamp.
* @param logger - channel for the warning.
* @returns timestamp of last emitted warning.
*/
static checkSocketUsage(agent, socketWarningTimestamp) {
var _a, _b;
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
var _a, _b, _c;
const { sockets, requests, maxSockets } = agent;

@@ -203,7 +205,7 @@ if (typeof maxSockets !== "number" || maxSockets === Infinity) {

if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
console.warn(
"@smithy/node-http-handler:WARN",
`socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.`,
"See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html",
"or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config."
(_c = logger == null ? void 0 : logger.warn) == null ? void 0 : _c.call(
logger,
`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`
);

@@ -234,3 +236,4 @@ return Date.now();

return new import_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
})()
})(),
logger: console
};

@@ -257,2 +260,3 @@ }

await writeRequestBodyPromise;
clearTimeout(socketCheckTimeoutId);
_reject(arg);

@@ -273,3 +277,7 @@ }, "reject");

() => {
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(
agent,
this.socketWarningTimestamp,
this.config.logger
);
},

@@ -321,8 +329,13 @@ this.config.socketAcquisitionWarningTimeout ?? (this.config.requestTimeout ?? 2e3) + (this.config.connectionTimeout ?? 1e3)

if (abortSignal) {
abortSignal.onabort = () => {
req.abort();
const onAbort = /* @__PURE__ */ __name(() => {
req.destroy();
const abortError = new Error("Request aborted");
abortError.name = "AbortError";
reject(abortError);
};
}, "onAbort");
if (typeof abortSignal.addEventListener === "function") {
abortSignal.addEventListener("abort", onAbort);
} else {
abortSignal.onabort = onAbort;
}
}

@@ -338,3 +351,6 @@ const httpAgent = nodeHttpsOptions.agent;

}
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch(_reject);
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch((e) => {
clearTimeout(socketCheckTimeoutId);
return _reject(e);
});
});

@@ -607,3 +623,3 @@ }

if (abortSignal) {
abortSignal.onabort = () => {
const onAbort = /* @__PURE__ */ __name(() => {
req.close();

@@ -613,3 +629,8 @@ const abortError = new Error("Request aborted");

rejectWithDestroy(abortError);
};
}, "onAbort");
if (typeof abortSignal.addEventListener === "function") {
abortSignal.addEventListener("abort", onAbort);
} else {
abortSignal.onabort = onAbort;
}
}

@@ -616,0 +637,0 @@ req.on("frameError", (type, code, id) => {

@@ -19,3 +19,3 @@ import { HttpResponse } from "@smithy/protocol-http";

}
static checkSocketUsage(agent, socketWarningTimestamp) {
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
const { sockets, requests, maxSockets } = agent;

@@ -34,3 +34,5 @@ if (typeof maxSockets !== "number" || maxSockets === Infinity) {

if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
console.warn("@smithy/node-http-handler:WARN", `socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.`, "See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html", "or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.");
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
return Date.now();

@@ -77,2 +79,3 @@ }

})(),
logger: console,
};

@@ -98,2 +101,3 @@ }

await writeRequestBodyPromise;
clearTimeout(socketCheckTimeoutId);
_reject(arg);

@@ -113,3 +117,3 @@ };

socketCheckTimeoutId = setTimeout(() => {
this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
}, this.config.socketAcquisitionWarningTimeout ??

@@ -161,4 +165,4 @@ (this.config.requestTimeout ?? 2000) + (this.config.connectionTimeout ?? 1000));

if (abortSignal) {
abortSignal.onabort = () => {
req.abort();
const onAbort = () => {
req.destroy();
const abortError = new Error("Request aborted");

@@ -168,2 +172,8 @@ abortError.name = "AbortError";

};
if (typeof abortSignal.addEventListener === "function") {
abortSignal.addEventListener("abort", onAbort);
}
else {
abortSignal.onabort = onAbort;
}
}

@@ -177,3 +187,6 @@ const httpAgent = nodeHttpsOptions.agent;

}
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch(_reject);
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch((e) => {
clearTimeout(socketCheckTimeoutId);
return _reject(e);
});
});

@@ -180,0 +193,0 @@ }

@@ -116,3 +116,3 @@ import { HttpResponse } from "@smithy/protocol-http";

if (abortSignal) {
abortSignal.onabort = () => {
const onAbort = () => {
req.close();

@@ -123,2 +123,8 @@ const abortError = new Error("Request aborted");

};
if (typeof abortSignal.addEventListener === "function") {
abortSignal.addEventListener("abort", onAbort);
}
else {
abortSignal.onabort = onAbort;
}
}

@@ -125,0 +131,0 @@ req.on("frameError", (type, code, id) => {

/// <reference types="node" />
/// <reference types="node" />
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
import type { NodeHttpHandlerOptions } from "@smithy/types";
import type { Logger, NodeHttpHandlerOptions } from "@smithy/types";
import { HttpHandlerOptions, Provider } from "@smithy/types";

@@ -26,5 +26,7 @@ import { Agent as hAgent } from "http";

* @param agent - http(s) agent in use by the NodeHttpHandler instance.
* @param socketWarningTimestamp - last socket usage check timestamp.
* @param logger - channel for the warning.
* @returns timestamp of last emitted warning.
*/
static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number): number;
static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number, logger?: Logger): number;
constructor(options?: NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>);

@@ -31,0 +33,0 @@ private resolveDefaultConfig;

/// <reference types="node" />
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
import { NodeHttpHandlerOptions } from "@smithy/types";
import { Logger, NodeHttpHandlerOptions } from "@smithy/types";
import { HttpHandlerOptions, Provider } from "@smithy/types";

@@ -25,5 +25,7 @@ import { Agent as hAgent } from "http";

* @param agent - http(s) agent in use by the NodeHttpHandler instance.
* @param socketWarningTimestamp - last socket usage check timestamp.
* @param logger - channel for the warning.
* @returns timestamp of last emitted warning.
*/
static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number): number;
static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number, logger?: Logger): number;
constructor(options?: NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>);

@@ -30,0 +32,0 @@ private resolveDefaultConfig;

{
"name": "@smithy/node-http-handler",
"version": "3.0.1",
"version": "3.1.0",
"description": "Provides a way to make requests",

@@ -10,3 +10,3 @@ "scripts": {

"build:types": "yarn g:tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"build:types:downlevel": "rimraf dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
"stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",

@@ -29,6 +29,6 @@ "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",

"dependencies": {
"@smithy/abort-controller": "^3.0.1",
"@smithy/protocol-http": "^4.0.1",
"@smithy/querystring-builder": "^3.0.1",
"@smithy/types": "^3.1.0",
"@smithy/abort-controller": "^3.1.0",
"@smithy/protocol-http": "^4.0.2",
"@smithy/querystring-builder": "^3.0.2",
"@smithy/types": "^3.2.0",
"tslib": "^2.6.2"

@@ -35,0 +35,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc