web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Unhandled promise rejection on `web3.eth.sendSignedTransaction`

Open arijoon opened this issue 1 year ago • 4 comments

Expected behavior

If server is closed during sendTransaction, process should not crash and exception must bubble up allowing the caller to catch it Under no circumstances the lib should be throwing unhandled exceptions and damaging the underlying process

Actual behavior

Unhandled exception is thrown and crashes the process

Steps to reproduce the behavior

  1. Create a mock server (simple express server would do)
  2. Set your mock server as the rpc url and construct web3 provider
  3. sign a tx and use web3.eth.sendSignedTransaction
  4. Mock a response to only the send part
  5. Close the server after send

Logs

    FetchError: request to http://localhost:63799/ failed, reason: connect ECONNREFUSED 127.0.0.1:63799

      at ClientRequest.<anonymous> (../.yarn/__virtual__/node-fetch-virtual-6f667efda9/3/home/USER/.yarn/berry/cache/node-fetch-npm-2.6.12-48619ce9d6-10c0.zip/node_modules/node-fetch/lib/index.js:1505:11)

Environment

Ubuntu web3: v4.4.0 node: v18.18.2

arijoon avatar Mar 14 '24 15:03 arijoon

Hey @arijoon thanks for submiting this, i'll ping the devs, could u pls provide the code/repo to try to reproduce it as well? Thanks!

SantiagoDevRel avatar Mar 14 '24 15:03 SantiagoDevRel

sure I'll try to make a sample repo for it over the weekend. For now I've opted to directly use sendRawTransaction from web3-rpc-methods as sendTransaction is doing the same under the hood and then waits for receipt which is undesired for our case

arijoon avatar Mar 14 '24 15:03 arijoon

Amazing, I appreciate it a lot👍

SantiagoDevRel avatar Mar 14 '24 15:03 SantiagoDevRel

Added a repo here: https://github.com/arijoon/web3-6900-reproduction

dependency versions used are in the readme but easiest to use nix to get a guarantee of a reproducible env

arijoon avatar Mar 14 '24 20:03 arijoon