ton-provider-system 0.1.4 → 0.1.6
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/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1315,6 +1315,8 @@ var TokenBucketRateLimiter = class {
|
|
|
1315
1315
|
if (this.currentBackoff > 0) {
|
|
1316
1316
|
this.logger.debug(`Applying backoff: ${this.currentBackoff}ms`);
|
|
1317
1317
|
await sleep(this.currentBackoff);
|
|
1318
|
+
this.lastRefill = Date.now();
|
|
1319
|
+
this.currentBackoff = 0;
|
|
1318
1320
|
}
|
|
1319
1321
|
while (this.tokens <= 0) {
|
|
1320
1322
|
if (Date.now() - startTime > timeoutMs) {
|
|
@@ -1364,6 +1366,7 @@ var TokenBucketRateLimiter = class {
|
|
|
1364
1366
|
);
|
|
1365
1367
|
}
|
|
1366
1368
|
this.tokens = 0;
|
|
1369
|
+
this.lastRefill = Date.now();
|
|
1367
1370
|
this.logger.warn(`Rate limit hit, backoff: ${this.currentBackoff}ms, errors: ${this.consecutiveErrors}`);
|
|
1368
1371
|
}
|
|
1369
1372
|
/**
|
|
@@ -1896,7 +1899,8 @@ var _ProviderManager = class _ProviderManager {
|
|
|
1896
1899
|
this.rateLimiter = createRateLimiterManager(this.options.logger);
|
|
1897
1900
|
for (const provider of this.registry.getAllProviders()) {
|
|
1898
1901
|
const config2 = getRateLimitForType(provider.type);
|
|
1899
|
-
const
|
|
1902
|
+
const bufferMultiplier = provider.rps <= 3 ? 1.2 : 1.1;
|
|
1903
|
+
const minDelayMs = Math.ceil(1e3 / provider.rps * bufferMultiplier);
|
|
1900
1904
|
let burstSize;
|
|
1901
1905
|
if (provider.rps <= 3) {
|
|
1902
1906
|
burstSize = 1;
|