Skip to content

Commit

Permalink
feat: make confirm transaction timeout configurable (solana-labs#19954)
Browse files Browse the repository at this point in the history
  • Loading branch information
oJshua authored Sep 17, 2021
1 parent 9998e16 commit 0404e75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web3.js/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1979,13 +1979,16 @@ export type ConnectionConfig = {
fetchMiddleware?: FetchMiddleware;
/** Optional Disable retring calls when server responds with HTTP 429 (Too Many Requests) */
disableRetryOnRateLimit?: boolean;
/** time to allow for the server to initially process a transaction (in milliseconds) */
confirmTransactionInitialTimeout?: number;
};

/**
* A connection to a fullnode JSON RPC endpoint
*/
export class Connection {
/** @internal */ _commitment?: Commitment;
/** @internal */ _confirmTransactionInitialTimeout?: number;
/** @internal */ _rpcEndpoint: string;
/** @internal */ _rpcWsEndpoint: string;
/** @internal */ _rpcClient: RpcClient;
Expand Down Expand Up @@ -2070,6 +2073,8 @@ export class Connection {
this._commitment = commitmentOrConfig;
} else if (commitmentOrConfig) {
this._commitment = commitmentOrConfig.commitment;
this._confirmTransactionInitialTimeout =
commitmentOrConfig.confirmTransactionInitialTimeout;
wsEndpoint = commitmentOrConfig.wsEndpoint;
httpHeaders = commitmentOrConfig.httpHeaders;
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
Expand Down Expand Up @@ -2629,14 +2634,14 @@ export class Connection {
}
});

let timeoutMs = 60 * 1000;
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
switch (subscriptionCommitment) {
case 'processed':
case 'recent':
case 'single':
case 'confirmed':
case 'singleGossip': {
timeoutMs = 30 * 1000;
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
break;
}
// exhaust enums to ensure full coverage
Expand Down

0 comments on commit 0404e75

Please sign in to comment.