hardhat-tracer icon indicating copy to clipboard operation
hardhat-tracer copied to clipboard

Terminal process hangs indefinitely after running tests with numerous contract calls

Open Confucian-e opened this issue 1 year ago • 3 comments

Description

When running tests using the test --v command (regardless of the number of v flags), the terminal process fails to terminate if there are numerous contract calls during the test execution. This issue persists even when attempting to close the terminal using Ctrl + C.

Steps to Reproduce

Set up a Hardhat project with multiple tests involving numerous contract calls. Run the tests using npx hardhat test --v (or --vv, --vvv, etc.). Wait for the tests to complete. Attempt to end the process or close the terminal.

Expected Behavior

The terminal process should end immediately after the tests complete or when interrupted with Ctrl + C.

Actual Behavior

The terminal process continues to run indefinitely, and Ctrl + C does not terminate it. The only way to end the process is to forcibly close the terminal window.

Environment

Operating System: MacOS Node.js version: v20.15.0

package.json

{
  "name": "hardhat-project",
  "devDependencies": {
    "@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
    "@nomicfoundation/hardhat-ethers": "^3.0.0",
    "@nomicfoundation/hardhat-ignition": "^0.15.0",
    "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.0",
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "@nomicfoundation/hardhat-verify": "^2.0.0",
    "@openzeppelin/hardhat-upgrades": "^3.2.1",
    "@openzeppelin/merkle-tree": "^1.0.7",
    "@typechain/ethers-v6": "^0.5.0",
    "@typechain/hardhat": "^9.0.0",
    "@types/chai": "^4.2.0",
    "@types/mocha": ">=9.1.0",
    "@types/node": ">=18.0.0",
    "chai": "^4.2.0",
    "ethers": "^6.4.0",
    "hardhat": "^2.22.6",
    "hardhat-abi-exporter": "^2.10.1",
    "hardhat-deal": "^3.1.1",
    "hardhat-gas-reporter": "^1.0.8",
    "hardhat-tracer": "^3.1.0",
    "ohash": "^1.1.3",
    "solidity-coverage": "^0.8.0",
    "ts-node": ">=8.0.0",
    "typechain": "^8.3.0",
    "typescript": ">=4.5.0"
  },
  "dependencies": {
    "@openzeppelin/contracts": "^5.0.2",
    "@openzeppelin/contracts-upgradeable": "^5.0.2"
  },
  "optionalDependencies": {
    "viem": "^2.18.8"
  }
}

Additional Context

This issue has been reproduced on multiple machines with different configurations. The problem seems to occur only when there are many contract calls during test execution. The issue is consistent across different levels of verbosity (-v, -vv, -vvv).

Possible Related Factors

High volume of contract calls during tests Interaction between hardhat-tracer and the test runner Potential memory leak or unhandled asynchronous operations

Any assistance in resolving this issue would be greatly appreciated. Please let me know if you need any additional information or if you'd like me to run any specific diagnostics.

Confucian-e avatar Aug 15 '24 08:08 Confucian-e

This is the first time using hardhat-tracer and hardhat-deal plugins together in this project. The tests make use of the deal(token, account, amount) function provided by hardhat-deal.

Confucian-e avatar Aug 15 '24 08:08 Confucian-e

Hi @Confucian-e , could you provide a minimal test case to reproduce the bug pls?

Something where deal is used and a contract call is made, leaving the process hanging. My first lead is to test whether the process still hangs if deal usage is removed

Rubilmax avatar Aug 19 '24 07:08 Rubilmax

I tried using both hardhat-deal along with hardhat-tracer in a fresh project. It seems to work, I do notice that deal function makes a bunch of balanceOf calls, but couldn't reproduce the hanging.

A repro would definitely help!

zemse avatar Sep 01 '24 19:09 zemse

I can confirm "Terminal process hangs indefinitely after running tests with numerous contract calls" I have a project with about 100 unit tests, which are more like integration tests rather a unit test, and it hangs after running about 10 tests if I run testing with --fulltrace option. Maybe it is some dead lock error because when I ran it with tracing node.js , it just stops running. Maybe using strace linux command would help to debug this, but the fact is, the bug is present in the code, and it is difficult to provide a reproduction scenario. Maybe wirting a simple test and copying it like 100 times??? but not sure.... maybe it is related to heavy EVM use.

nuliknol avatar Mar 27 '25 17:03 nuliknol

I confirm this issue too.

nikicat avatar Apr 01 '25 20:04 nikicat