fix(server): remove dead blockchain init block that threw swallowed ReferenceError - #1348
Open
saidai-bhuvanesh wants to merge 1 commit into
Open
Conversation
…eferenceError server.js constructed new ethers.JsonRpcProvider/Wallet/Contract using 'ethers' and 'blockchainService' without importing either, so when INFURA_URL/CONTRACT_ADDRESS/PRIVATE_KEY were set the block threw ReferenceError: ethers is not defined. The surrounding catch swallowed it, logging 'Failed to initialize blockchain connection' on every boot while contractInstance stayed null and was never read anywhere. The real blockchain connection is initialized through blockchainService.initialize() at startup (startup/bootstrap.js -> config/blockchain.js, which imports ethers and the ABI correctly), so this duplicate dead block is removed. Closes Nitya-003#1238
|
@openhands-agent is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1238
backend/server.jsconstructednew ethers.JsonRpcProvider/Wallet/Contract(... blockchainService.getContractABI() ...)but never importedethersorblockchainServicein that file. WhenINFURA_URL/CONTRACT_ADDRESS/PRIVATE_KEYwere set, the block threwReferenceError: ethers is not defined, which the surroundingcatchswallowed — so the app loggedFailed to initialize blockchain connectionon every boot and continued withcontractInstance = null. A real connection was never attempted through this path.Fix
The real blockchain connection is already initialized correctly at startup via
blockchainService.initialize()→config/blockchain.js(which importsethersand the contract ABI). Seestartup/bootstrap.js:46. The duplicate block inserver.jswas dead code — its module-localprovider/wallet/contractInstancewere never read anywhere. Per the issue's guidance ("or drops the unused block"), I removed the dead block and its unused locals, keeping the production safety guard intact.Files
backend/server.jsThis PR was created by an AI agent (OpenHands) on behalf of @saidai-bhuvanesh.