@solana/web3.js 1.16.2 → 1.17.1

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/lib/index.d.ts CHANGED
@@ -1292,6 +1292,8 @@ declare module '@solana/web3.js' {
1292
1292
  httpHeaders?: HttpHeaders;
1293
1293
  /** Optional fetch middleware callback */
1294
1294
  fetchMiddleware?: FetchMiddleware;
1295
+ /** Optional Disable retring calls when server responds with HTTP 429 (Too Many Requests) */
1296
+ disableRetryOnRateLimit?: boolean;
1295
1297
  };
1296
1298
  /**
1297
1299
  * A connection to a fullnode JSON RPC endpoint
package/lib/index.esm.js CHANGED
@@ -2555,7 +2555,7 @@ const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
2555
2555
  logs: nullable(array(string()))
2556
2556
  }));
2557
2557
 
2558
- function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware) {
2558
+ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
2559
2559
  let agentManager;
2560
2560
 
2561
2561
  {
@@ -2607,6 +2607,10 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware) {
2607
2607
  break;
2608
2608
  }
2609
2609
 
2610
+ if (disableRetryOnRateLimit === true) {
2611
+ break;
2612
+ }
2613
+
2610
2614
  too_many_requests_retries -= 1;
2611
2615
 
2612
2616
  if (too_many_requests_retries === 0) {
@@ -3340,6 +3344,7 @@ class Connection {
3340
3344
  let wsEndpoint;
3341
3345
  let httpHeaders;
3342
3346
  let fetchMiddleware;
3347
+ let disableRetryOnRateLimit;
3343
3348
 
3344
3349
  if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
3345
3350
  this._commitment = commitmentOrConfig;
@@ -3348,11 +3353,12 @@ class Connection {
3348
3353
  wsEndpoint = commitmentOrConfig.wsEndpoint;
3349
3354
  httpHeaders = commitmentOrConfig.httpHeaders;
3350
3355
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
3356
+ disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
3351
3357
  }
3352
3358
 
3353
3359
  this._rpcEndpoint = endpoint;
3354
3360
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
3355
- this._rpcClient = createRpcClient(url.href, useHttps, httpHeaders, fetchMiddleware);
3361
+ this._rpcClient = createRpcClient(url.href, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit);
3356
3362
  this._rpcRequest = createRpcRequest(this._rpcClient);
3357
3363
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
3358
3364
  this._rpcWebSocket = new Client(this._rpcWsEndpoint, {