You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: cherry pick #3368 fix: added polling logic to ensure the retrieval of fully mature records from MN (#3370)
fix: added polling logic to ensure the retrieval of fully mature records from MN (#3368)
* fix: added polling logic to getContractResultWithRetry() and getContractResultsLogsWithRetry()
* fix: strictly throw errors if immature records found
---------
Signed-off-by: Logan Nguyen <[email protected]>
`${requestDetails.formattedRequestId} Contract result contains undefined transaction_index, block_number, or block_hash is an empty hex (0x): transaction_hash:${contractObject.hash}, transaction_index:${contractObject.transaction_index}, block_number=${contractObject.block_number}, block_hash=${contractObject.block_hash}. Retrying after a delay of ${shortDelay} ms `,
// Found immature record, log the info, set flag and exit record traversal
799
+
if(this.logger.isLevelEnabled('debug')){
800
+
this.logger.debug(
801
+
`${
802
+
requestDetails.formattedRequestId
803
+
} Contract result contains nullable transaction_index or block_number, or block_hash is an empty hex (0x): contract_result=${JSON.stringify(
804
+
contractObject,
805
+
)}. Retrying after a delay of ${mirrorNodeRetryDelay} ms `,
806
+
);
807
+
}
808
+
809
+
foundImmatureRecord=true;
810
+
break;
787
811
}
788
-
789
-
// Backoff before repeating request
790
-
awaitnewPromise((r)=>setTimeout(r,shortDelay));
791
-
returnawaitthis[methodName](...args);
792
812
}
813
+
814
+
// if foundImmatureRecord is still false after record traversal, it means no immature record was found. Simply return contractResult to stop the polling process
815
+
if(!foundImmatureRecord)returncontractResult;
816
+
817
+
// if immature record found, wait and retry and update contractResult
`${requestDetails.formattedRequestId} Contract result log contains undefined transaction_index, block_number, index, or block_hash is an empty hex (0x): transaction_hash:${log.transaction_hash}, transaction_index:${log.transaction_index}, block_number=${log.block_number}, log_index=${log.index}, block_hash=${log.block_hash}. Retrying after a delay of ${shortDelay} ms.`,
937
-
);
967
+
for(leti=0;i<mirrorNodeRequestRetryCount;i++){
968
+
if(logResults){
969
+
letfoundImmatureRecord=false;
970
+
971
+
for(constlogoflogResults){
972
+
if(
973
+
log&&
974
+
(log.transaction_index==null||
975
+
log.block_number==null||
976
+
log.index==null||
977
+
log.block_hash===EthImpl.emptyHex)
978
+
){
979
+
// Found immature record, log the info, set flag and exit record traversal
980
+
if(this.logger.isLevelEnabled('debug')){
981
+
this.logger.debug(
982
+
`${
983
+
requestDetails.formattedRequestId
984
+
} Contract result log contains undefined transaction_index, block_number, index, or block_hash is an empty hex (0x): log=${JSON.stringify(
985
+
log,
986
+
)}. Retrying after a delay of ${mirrorNodeRetryDelay} ms.`,
// if foundImmatureRecord is still false after record traversal, it means no immature record was found. Simply return logResults to stop the polling process
996
+
if(!foundImmatureRecord)returnlogResults;
997
+
998
+
// if immature record found, wait and retry and update logResults
`${requestIdPrefix} getTransactionByHash(hash=${hash}) mirror-node returned status 200 with missing properties in contract_results - block_number==${contractResult.block_number} and transaction_index==${contractResult.transaction_index}`,
0 commit comments