feat: make confirm transaction timeout configurable (#19954)
This commit is contained in:
@ -1979,6 +1979,8 @@ export type ConnectionConfig = {
|
|||||||
fetchMiddleware?: FetchMiddleware;
|
fetchMiddleware?: FetchMiddleware;
|
||||||
/** Optional Disable retring calls when server responds with HTTP 429 (Too Many Requests) */
|
/** Optional Disable retring calls when server responds with HTTP 429 (Too Many Requests) */
|
||||||
disableRetryOnRateLimit?: boolean;
|
disableRetryOnRateLimit?: boolean;
|
||||||
|
/** time to allow for the server to initially process a transaction (in milliseconds) */
|
||||||
|
confirmTransactionInitialTimeout?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1986,6 +1988,7 @@ export type ConnectionConfig = {
|
|||||||
*/
|
*/
|
||||||
export class Connection {
|
export class Connection {
|
||||||
/** @internal */ _commitment?: Commitment;
|
/** @internal */ _commitment?: Commitment;
|
||||||
|
/** @internal */ _confirmTransactionInitialTimeout?: number;
|
||||||
/** @internal */ _rpcEndpoint: string;
|
/** @internal */ _rpcEndpoint: string;
|
||||||
/** @internal */ _rpcWsEndpoint: string;
|
/** @internal */ _rpcWsEndpoint: string;
|
||||||
/** @internal */ _rpcClient: RpcClient;
|
/** @internal */ _rpcClient: RpcClient;
|
||||||
@ -2070,6 +2073,8 @@ export class Connection {
|
|||||||
this._commitment = commitmentOrConfig;
|
this._commitment = commitmentOrConfig;
|
||||||
} else if (commitmentOrConfig) {
|
} else if (commitmentOrConfig) {
|
||||||
this._commitment = commitmentOrConfig.commitment;
|
this._commitment = commitmentOrConfig.commitment;
|
||||||
|
this._confirmTransactionInitialTimeout =
|
||||||
|
commitmentOrConfig.confirmTransactionInitialTimeout;
|
||||||
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
||||||
httpHeaders = commitmentOrConfig.httpHeaders;
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
||||||
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
||||||
@ -2629,14 +2634,14 @@ export class Connection {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let timeoutMs = 60 * 1000;
|
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
||||||
switch (subscriptionCommitment) {
|
switch (subscriptionCommitment) {
|
||||||
case 'processed':
|
case 'processed':
|
||||||
case 'recent':
|
case 'recent':
|
||||||
case 'single':
|
case 'single':
|
||||||
case 'confirmed':
|
case 'confirmed':
|
||||||
case 'singleGossip': {
|
case 'singleGossip': {
|
||||||
timeoutMs = 30 * 1000;
|
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// exhaust enums to ensure full coverage
|
// exhaust enums to ensure full coverage
|
||||||
|
Reference in New Issue
Block a user