1
+ import { Logger } from "winston" ;
1
2
import { RpcTransport , SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR } from "@solana/kit" ;
2
3
import { getThrowSolanaErrorResponseTransformer } from "@solana/rpc-transformers" ;
4
+ import { isSolanaError } from "../../arch/svm" ;
5
+ import { delay } from "../../utils" ;
3
6
import { SolanaClusterRpcFactory } from "./baseRpcFactories" ;
4
7
import { RateLimitedSolanaRpcFactory } from "./rateLimitedRpcFactory" ;
5
- import { isSolanaError , SVM_SLOT_SKIPPED , SVM_LONG_TERM_STORAGE_SLOT_SKIPPED } from "../../arch/svm" ;
6
- import { delay } from "../../utils" ;
7
- import { Logger } from "winston" ;
8
+ import { shouldFailImmediate } from "./utils" ;
8
9
9
10
// This factory adds retry logic on top of the RateLimitedSolanaRpcFactory.
10
11
// It follows the same composition pattern as other factories in this module.
@@ -67,7 +68,7 @@ export class RetrySolanaRpcFactory extends SolanaClusterRpcFactory {
67
68
getThrowSolanaErrorResponseTransformer ( ) ( response , { methodName : method , params } ) ;
68
69
return response ;
69
70
} catch ( error ) {
70
- if ( retryAttempt ++ >= this . retries || this . shouldFailImmediate ( method , error ) ) {
71
+ if ( retryAttempt ++ >= this . retries || shouldFailImmediate ( method , error ) ) {
71
72
throw error ;
72
73
}
73
74
@@ -82,29 +83,6 @@ export class RetrySolanaRpcFactory extends SolanaClusterRpcFactory {
82
83
}
83
84
}
84
85
85
- /**
86
- * Determine whether a Solana RPC error indicates an unrecoverable error that should not be retried.
87
- * @param method RPC method name
88
- * @param error Error object from the RPC call
89
- * @returns True if the request should be aborted immediately, otherwise false
90
- */
91
- private shouldFailImmediate ( method : string , error : unknown ) : boolean {
92
- if ( ! isSolanaError ( error ) ) {
93
- return false ;
94
- }
95
-
96
- // JSON-RPC errors: https://www.quicknode.com/docs/solana/error-references
97
- const { __code : code } = error . context ;
98
- switch ( method ) {
99
- case "getBlock" :
100
- case "getBlockTime" :
101
- // No block at the requested slot. This may not be correct for blocks > 1 year old.
102
- return [ SVM_SLOT_SKIPPED , SVM_LONG_TERM_STORAGE_SLOT_SKIPPED ] . includes ( code ) ;
103
- default :
104
- return false ;
105
- }
106
- }
107
-
108
86
/**
109
87
* Identify whether an error thrown was the result of an RPC provider 429 response.
110
88
* @param error Error object from the RPC query.
0 commit comments