Updated dist files.

This commit is contained in:
Richard Moore 2020-07-15 14:00:36 -04:00
parent 7d43545303
commit b1166211e2
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
15 changed files with 66 additions and 27 deletions

View File

@ -3,9 +3,10 @@ Changelog
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
ethers/v5.0.6 (2020-07-14 02:32)
ethers/v5.0.6 (2020-07-14 22:56)
--------------------------------
- Added Retry-After support and adjustable slot interval to fetchJson. ([7d43545](https://github.com/ethers-io/ethers.js/commit/7d435453039f009b339d835ddee47e35a843711b))
- Added initial throttling support. ([#139](https://github.com/ethers-io/ethers.js/issues/139), [#904](https://github.com/ethers-io/ethers.js/issues/904), [#926](https://github.com/ethers-io/ethers.js/issues/926); [88c7eae](https://github.com/ethers-io/ethers.js/commit/88c7eaed061ae9a6798733a97e4e87011d36b8e7))
- Use status code 1000 on WebSocket hangup for compatibility. ([588f64c](https://github.com/ethers-io/ethers.js/commit/588f64c760ee49bfb5109bfbaafb4beafe41c52a))
- Updated WebSocketProvider to use web-style event listener API. ([57fd6f0](https://github.com/ethers-io/ethers.js/commit/57fd6f06047a1a2a3a46fe8b23ff585293a40062))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19458,6 +19458,8 @@ function fetchJson(connection, json, processFunc) {
const attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
logger$p.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
const throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
const throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
logger$p.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
const headers = {};
let url = null;
// @TODO: Allow ConnectionInfo to override some of these values
@ -19540,15 +19542,22 @@ function fetchJson(connection, json, processFunc) {
let response = null;
try {
response = yield getUrl(url, options);
// Exponential back-off throttling (interval = 100ms)
// Exponential back-off throttling
if (response.statusCode === 429 && attempt < attemptLimit) {
let tryAgain = true;
if (throttleCallback) {
tryAgain = yield throttleCallback(attempt, url);
}
if (tryAgain) {
const timeout = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
yield staller(timeout);
let stall = 0;
const retryAfter = response.headers["retry-after"];
if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
}
yield staller(stall);
continue;
}
}
@ -19608,7 +19617,7 @@ function fetchJson(connection, json, processFunc) {
tryAgain = yield throttleCallback(attempt, url);
}
if (tryAgain) {
const timeout = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
const timeout = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
yield staller(timeout);
continue;
}

File diff suppressed because one or more lines are too long

View File

@ -21316,6 +21316,8 @@
var attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
var throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
var throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
var headers = {};
var url = null;
// @TODO: Allow ConnectionInfo to override some of these values
@ -21394,7 +21396,7 @@
})();
var runningFetch = (function () {
return __awaiter(this, void 0, void 0, function () {
var attempt, response, tryAgain, timeout_1, error_1, body, json_1, error_2, tryAgain, timeout_2;
var attempt, response, tryAgain, stall, retryAfter, error_1, body, json_1, error_2, tryAgain, timeout_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@ -21418,8 +21420,15 @@
_a.label = 5;
case 5:
if (!tryAgain) return [3 /*break*/, 7];
timeout_1 = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_1)];
stall = 0;
retryAfter = response.headers["retry-after"];
if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
}
return [4 /*yield*/, staller(stall)];
case 6:
_a.sent();
return [3 /*break*/, 18];
@ -21488,8 +21497,8 @@
_a.label = 14;
case 14:
if (!tryAgain) return [3 /*break*/, 16];
timeout_2 = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_2)];
timeout_1 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_1)];
case 15:
_a.sent();
return [3 /*break*/, 18];

File diff suppressed because one or more lines are too long

View File

@ -49,7 +49,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x930c9c8ccf1f6fcda0433634b0642e46949ddd18ea54063c3285047ed9945856",
"tarballHash": "0x0c02e224b11fb85cf79b867a703cb5a721b5eb908c09090ecf09e8ca74fccae7",
"types": "./lib/index.d.ts",
"version": "5.0.6"
}

View File

@ -7,6 +7,7 @@ export declare type ConnectionInfo = {
password?: string;
allowInsecureAuthentication?: boolean;
throttleLimit?: number;
throttleSlotInterval?: number;
throttleCallback?: (attempt: number, url: string) => Promise<boolean>;
timeout?: number;
};

View File

@ -25,6 +25,8 @@ export function fetchJson(connection, json, processFunc) {
const attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
const throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
const throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
const headers = {};
let url = null;
// @TODO: Allow ConnectionInfo to override some of these values
@ -107,15 +109,22 @@ export function fetchJson(connection, json, processFunc) {
let response = null;
try {
response = yield getUrl(url, options);
// Exponential back-off throttling (interval = 100ms)
// Exponential back-off throttling
if (response.statusCode === 429 && attempt < attemptLimit) {
let tryAgain = true;
if (throttleCallback) {
tryAgain = yield throttleCallback(attempt, url);
}
if (tryAgain) {
const timeout = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
yield staller(timeout);
let stall = 0;
const retryAfter = response.headers["retry-after"];
if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
}
yield staller(stall);
continue;
}
}
@ -175,7 +184,7 @@ export function fetchJson(connection, json, processFunc) {
tryAgain = yield throttleCallback(attempt, url);
}
if (tryAgain) {
const timeout = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
const timeout = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
yield staller(timeout);
continue;
}

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@ export declare type ConnectionInfo = {
password?: string;
allowInsecureAuthentication?: boolean;
throttleLimit?: number;
throttleSlotInterval?: number;
throttleCallback?: (attempt: number, url: string) => Promise<boolean>;
timeout?: number;
};

View File

@ -53,6 +53,8 @@ function fetchJson(connection, json, processFunc) {
var attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
var throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
var throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
var headers = {};
var url = null;
// @TODO: Allow ConnectionInfo to override some of these values
@ -131,7 +133,7 @@ function fetchJson(connection, json, processFunc) {
})();
var runningFetch = (function () {
return __awaiter(this, void 0, void 0, function () {
var attempt, response, tryAgain, timeout_1, error_1, body, json_1, error_2, tryAgain, timeout_2;
var attempt, response, tryAgain, stall, retryAfter, error_1, body, json_1, error_2, tryAgain, timeout_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@ -155,8 +157,15 @@ function fetchJson(connection, json, processFunc) {
_a.label = 5;
case 5:
if (!tryAgain) return [3 /*break*/, 7];
timeout_1 = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_1)];
stall = 0;
retryAfter = response.headers["retry-after"];
if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
}
return [4 /*yield*/, staller(stall)];
case 6:
_a.sent();
return [3 /*break*/, 18];
@ -225,8 +234,8 @@ function fetchJson(connection, json, processFunc) {
_a.label = 14;
case 14:
if (!tryAgain) return [3 /*break*/, 16];
timeout_2 = 100 * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_2)];
timeout_1 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
return [4 /*yield*/, staller(timeout_1)];
case 15:
_a.sent();
return [3 /*break*/, 18];

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0xc22676625b8063465d9d8d59169c0beb6eaeb70af3743d98fc8f2b4d826a70c8",
"tarballHash": "0x706e9cf2a72162332269c71f0e1c5ca6dbaa252e627710ed676fd342dbe89e40",
"types": "./lib/index.d.ts",
"version": "5.0.2"
}