From 4c36f55f2c8e9f8b393d8919b05d7abb46cb2432 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 25 Jun 2024 09:11:45 -0400 Subject: [PATCH] fix waitingforreceipt error (#7098) * fix waitingforreceipt error * update cach * remove comment * throw other errors * update changelog and text * update linter --- packages/web3-eth/CHANGELOG.md | 6 +++++- packages/web3-eth/src/rpc_method_wrappers.ts | 21 +++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/web3-eth/CHANGELOG.md b/packages/web3-eth/CHANGELOG.md index 2b6c0e08005..ba620044bde 100644 --- a/packages/web3-eth/CHANGELOG.md +++ b/packages/web3-eth/CHANGELOG.md @@ -256,4 +256,8 @@ Documentation: - WebEth has `setTransactionMiddleware` and `getTransactionMiddleware` for automatically passing to `sentTransaction` (#7088) - `TransactionMiddleware` and `TransactionMiddleware` data types are exported (#7088) -## [Unreleased] \ No newline at end of file +## [Unreleased] + +### Fixed + +- Fixed geth issue when running a new instance, transactions will index when there are no blocks created (#7098) \ No newline at end of file diff --git a/packages/web3-eth/src/rpc_method_wrappers.ts b/packages/web3-eth/src/rpc_method_wrappers.ts index 336aef3a23d..3a03afe0967 100644 --- a/packages/web3-eth/src/rpc_method_wrappers.ts +++ b/packages/web3-eth/src/rpc_method_wrappers.ts @@ -496,11 +496,22 @@ export async function getTransactionReceipt( transactionHash, DEFAULT_RETURN_FORMAT, ); - const response = await ethRpcMethods.getTransactionReceipt( - web3Context.requestManager, - transactionHashFormatted, - ); - + let response; + try { + response = await ethRpcMethods.getTransactionReceipt( + web3Context.requestManager, + transactionHashFormatted, + ); + } catch (error) { + // geth indexing error, we poll until transactions stopped indexing + if (typeof error === 'object' && !isNullish(error) && 'message' in error && (error as { message: string }).message === 'transaction indexing is in progress') { + console.warn('Transaction indexing is in progress.') + } else { + throw error; + } + + } + return isNullish(response) ? response : (format(