hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Undici timeouts are not handled correctly

Open alcuadrado opened this issue 3 years ago • 13 comments

When upgrading to undici we introduced two problems:

  1. We are not passing the bodyTimeout here
  2. The way we are detecting if an error is a timeout is outdated here

Related to https://github.com/NomicFoundation/hardhat/issues/2672

alcuadrado avatar Sep 05 '22 17:09 alcuadrado

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: 14ad93d2-d907-4826-a94c-3e9132847d06

github-actions[bot] avatar Sep 05 '22 17:09 github-actions[bot]

Is this issue open to work?

ernestosperanza avatar Sep 12 '22 13:09 ernestosperanza

@ernestosperanza sure, but make sure that you can reproduce the issue (check #2672) and that your fix indeed fixes it (see https://github.com/NomicFoundation/hardhat/blob/main/CONTRIBUTING.md#developing-locally to learn how to test a fix locally).

fvictorio avatar Sep 20 '22 18:09 fvictorio

is this issue available to solve?

Saty248 avatar Dec 20 '22 15:12 Saty248

It is, but check my previous comment.

fvictorio avatar Dec 21 '22 18:12 fvictorio

This is a blocking problem for me. Hoping we get a solution soon.

Its worth noting that I see this problem (code "UND_ERR_HEADERS_TIMEOUT" only when I run on LocalHost. When I run the same code on on the transient bockchain (with hh test) I get no error.

grapevinegizmos avatar Jan 31 '23 13:01 grapevinegizmos

Workaround from @samlaf : https://github.com/NomicFoundation/hardhat/issues/2672#issuecomment-1167409582 Example workaround implementation: https://github.com/web3well/bls-wallet/pull/341/files#diff-a2a940145025870fd09caa9fa093009d69793c78c5c9203195280575e5e4efb1R138-R143

jacque006 avatar Jan 31 '23 15:01 jacque006

I started working on this in #3665

alcuadrado avatar Feb 10 '23 23:02 alcuadrado

SocketError: other side closed
    at Socket.onSocketEnd (/home/ubuntu/paraspace-core/node_modules/undici/lib/client.js:995:22)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'UND_ERR_SOCKET',
  socket: {
    localAddress: '127.0.0.1',
    localPort: 36506,
    remoteAddress: undefined,
    remotePort: undefined,
    remoteFamily: undefined,
    timeout: undefined,
    bytesWritten: 616,
    bytesRead: 678
  }
}

is this error relevant? @alcuadrado @fvictorio I got this error when I run hardhat node on a VPS, but I cannot reproduce it locally on my PC

I cannot add timeout field to hardhat network config image

0x8f701 avatar Jun 28 '23 01:06 0x8f701

I'm having a similar issue to https://github.com/NomicFoundation/hardhat/issues/2672 with requests that take more than ~20s, it seems that the Hardhat provider (more specifically Undici) will timeout. If anyone is in a similar situation, using the Ethers provider JsonRpcProvider instead of Hardhat seems to do the trick.

0xCourtney avatar Mar 15 '24 19:03 0xCourtney

Any update on this? Or workaround? I have the issue when trying to deploy smart contract on the Hedera Mainnet.

insider89 avatar Jun 25 '24 13:06 insider89