NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.31k stars 1.41k forks source link

Getting error HH4 when attaching debugger #4081

Closed yaron-zilliqa closed 1 year ago

yaron-zilliqa commented 1 year ago

Version of Hardhat

2.15.0

What happened?

Attempting to debug a hardhat test by running: DEBUG=true MOCHA_TIMEOUT=300000 node --inspect-brk -r hardhat/register -r dotenv/config node_modules/.bin/hardhat test test/BasicInterop.ts --network localdev2

After attaching the debugger using Chrome and continuing the execution (with F8), I get:

Error HH4: HardhatContext is already created.

Minimal reproduction steps

I didn't manage to attach a debugger and reproduct source maps for the tests so the only way I managed to connect a debugger is using the above command line. Once attached, click F8.

Search terms

No response

fvictorio commented 1 year ago

Hi @yaron-zilliqa.

The problem is that you are running Hardhat and using -r hardhat/register. Try removing the -r hardhat/register and see if that works. I tried with a simple project and was able to connect the debugger to the tests.

I'm tentatively closing this, I'll re-open if that doesn't fix the problem for you.