Skip to content

fix(server): remove dead blockchain init block that threw swallowed ReferenceError - #1348

Open
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/1238-remove-dead-blockchain-init
Open

fix(server): remove dead blockchain init block that threw swallowed ReferenceError#1348
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/1238-remove-dead-blockchain-init

Conversation

@saidai-bhuvanesh

Copy link
Copy Markdown
Contributor

Summary

Fixes #1238

backend/server.js constructed new ethers.JsonRpcProvider/Wallet/Contract(... blockchainService.getContractABI() ...) but never imported ethers or blockchainService in that file. When INFURA_URL/CONTRACT_ADDRESS/PRIVATE_KEY were set, the block threw ReferenceError: ethers is not defined, which the surrounding catch swallowed — so the app logged Failed to initialize blockchain connection on every boot and continued with contractInstance = 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 imports ethers and the contract ABI). See startup/bootstrap.js:46. The duplicate block in server.js was dead code — its module-local provider/wallet/contractInstance were 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.js

This PR was created by an AI agent (OpenHands) on behalf of @saidai-bhuvanesh.

…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
@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix dead blockchain initialization in server.js

2 participants