Search code examples
localhosthardhat

TypeError: state.buffer is not iterable when using Hardhat


I followed the instruction as hardhat's https://hardhat.org/getting-started/ .

  1. npx hardhat node. And then I can connect to it with metamask.

  2. npx hardhat run scripts/sample-script.js --network localhost to deploy the example.

But it returns me as below error:

TypeError: state.buffer is not iterable

like below:

$ npx hardhat run scripts/sample-script.js --network localhost


/Users/********/workspace/testHardhat1/node_modules/undici/lib/api/readable.js:211

  for (const chunk of state.buffer) {

                            ^
TypeError: state.buffer is not iterable
    at consumeStart 
(/Users/******/workspace/testHardhat1/node_modules/undici/lib/api/readable.js:211:29)

    at processTicksAndRejections 
(internal/process/task_queues.js:83:17)


Solution

  • Try updating your node version, I was using a node version that is non-compatible with hardhat (Version 10.01) and after update to 16.14.0 that issue was fixed.