Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardhat compile randomly and quietly stops before compiling contracts #3877

Closed
sebastiendan opened this issue Apr 24, 2023 · 10 comments · Fixed by #4075
Closed

hardhat compile randomly and quietly stops before compiling contracts #3877

sebastiendan opened this issue Apr 24, 2023 · 10 comments · Fixed by #4075
Assignees
Labels
status:blocked Blocked by other issues or external reasons type:bug Something isn't working

Comments

@sebastiendan
Copy link

sebastiendan commented Apr 24, 2023

Edit by @fvictorio: Hardhat 2.16.1 should this problem.


Version of Hardhat

2.14.0

What happened?

npx hardhat compile sometimes goes on with compiling contracts and sometimes (seems totally random) silently stops at the Downloading compiler ... step before any contracts are actually compiled. This issue is reproducible with no contracts already compiled and in docker.

Minimal reproduction steps

Here's a simple repository where you can observe the problem: repo.

This CI workflow run shows in the logs that the compilation didn't happen: log.

In addition, one can run the docker container in interactive mode and manually run the build command to see that, again, the command sometimes doesn't build nor throws an error but simply quietly stops without compiling (same output as the CI log above):

  • Run the container in interactive mode: docker run --rm -it ghcr.io/sebastiendan/hardhat-compile-issue:main bash
  • Run the compile command: npm run build
  • Observe sometimes an actual compilation, sometimes a quiet stop in the command execution
    (run the above multiple times by exiting the container and re-running the two commands above)

Search terms

no compilation

@fuxingloh
Copy link

See:

This is due to a regression in the latest node versions 18 and 20. Somewhere after "Downloading compiler list for platform" when trying to a compiler, it failed to download it and failed silently.

Try to use a node version other than the latest. I'm surprised the node team hasn't done a release yet since this is a widespread issue.

@stefiix92
Copy link

@fuxingloh thanks for pointing that out, I tried node 18.12.1 and the issue disappeared!

@sebastiendan
Copy link
Author

@fuxingloh I can confirm it works with the 18.15.0-slim docker tag of node 👍

@fvictorio
Copy link
Member

Wow, this is so weird. Thanks everyone for the info.

I still don't quite understand why and when this happens, but it's good to know that changing the version of node fixes the issue.

@sebastiendan I'm going to edit your issue so this information shows up first for people landing here.

@fvictorio fvictorio pinned this issue Apr 25, 2023
@jubeira
Copy link

jubeira commented Apr 25, 2023

FWIW, Github actions is currently using 18.16.0 in Ubuntu 20 / 22 (latest) if the Node version is specified just as 18: actions/runner-images@af6dd20.

Specifying a different minor version (e.g node-version: 18.15) indeed solves the problem.

ryscheng added a commit to hypercerts-org/hypercerts that referenced this issue Apr 26, 2023
* Separate build:deploy command for compiling for deployment
* Fixing our node version to 18.15.0 for now while we wait for a fix for
  NomicFoundation/hardhat#3877
ryscheng added a commit to hypercerts-org/hypercerts that referenced this issue Apr 26, 2023
* Separate build:deploy command for compiling for deployment
* Fixing our node version to 18.15.0 for now while we wait for a fix for
  NomicFoundation/hardhat#3877
ryscheng added a commit to hypercerts-org/hypercerts that referenced this issue Apr 26, 2023
* Separate build:deploy command for compiling for deployment
* Fixing our node version to 18.15.0 for now while we wait for a fix for
  NomicFoundation/hardhat#3877
ryscheng added a commit to hypercerts-org/hypercerts that referenced this issue Apr 26, 2023
* Separate build:deploy command for compiling for deployment
* Fixing our node version to 18.15.0 for now while we wait for a fix for
  NomicFoundation/hardhat#3877
asaj added a commit to hyperlane-xyz/hyperlane-monorepo that referenced this issue Apr 26, 2023
geoknee added a commit to statechannels/go-nitro that referenced this issue Apr 27, 2023
@fvictorio fvictorio added status:blocked Blocked by other issues or external reasons and removed status:triaging labels Apr 27, 2023
0xalpharush added a commit to crytic/medusa that referenced this issue Apr 28, 2023
Fixes flaky hardhat compilation until a node release is made
NomicFoundation/hardhat#3877
@fvictorio
Copy link
Member

Honestly, I thought they were going to release a fix sooner. I'll see if there's some workaround we can implement on our side.

@fvictorio fvictorio added the type:bug Something isn't working label Jun 22, 2023
felipetavares added a commit to immutable/wallet-contracts that referenced this issue Jun 23, 2023
@fvictorio fvictorio self-assigned this Jun 26, 2023
michalinacienciala added a commit to threshold-network/solidity-contracts that referenced this issue Jun 27, 2023
We want to fix problem with the `yarn build` (`hardhat compile`) command
sometimes not generating expected artifacts. The problem is caused by the
process silently quitting, which is related to the used version of Node (as
descibed in NomicFoundation/hardhat#3877). We've confirmed the problem is
reproducible on `v18.16.0`, now we're downgrading to `v18.15.0` to fix the
issue.
pdyraga added a commit to threshold-network/solidity-contracts that referenced this issue Jun 27, 2023
…ther

Set Node.js version to 18.15.0

We want to fix problem with the yarn build (hardhat compile) command sometimes not generating expected artifacts. The problem is caused by the process silently quitting, which is related to the used version of Node (as descibed in NomicFoundation/hardhat#3877). We've confirmed the problem is reproducible on v18.16.0, now we're downgrading to v18.15.0 to fix the issue.
@fvictorio
Copy link
Member

Hi everyone, we just released Hardaht v2.16.1 which should fix this problem.

@fvictorio fvictorio unpinned this issue Jul 4, 2023
outerlook pushed a commit to usherlabs/logstore-mirror that referenced this issue Jul 10, 2023
sirpy added a commit to GoodDollar/GoodCollective that referenced this issue Aug 17, 2023
fleupold added a commit to cowprotocol/contracts that referenced this issue Aug 25, 2023
When currently building the docker image of the contract, we are not
including any artefacts, which - when running any hardhat script -
yields the following error:

```
HardhatError: HH700: Artifact for contract "src/contracts/interfaces/IERC20.sol:IERC20" not found. 
```

When looking at the build history we can see a subtle difference between
a build [that is
working](https://github.com/cowprotocol/contracts/actions/runs/5974729999/job/16209505930#step:5:253)
and [one that
isn't](https://github.com/cowprotocol/contracts/actions/runs/5975825913/job/16212645253#step:5:248):

```
#11 0.750 $ hardhat compile --force
#11 4.073 Warning: unable to recover token list from 1inch
#11 4.364 Downloading compiler 0.7.6
#11 4.826 Downloading compiler 0.7.6
**#11 17.88 Compiled 58 Solidity files successfully**
#11 18.27 $ tsc && tsc -p tsconfig.lib.esm.json && tsc -p tsconfig.lib.commonjs.json
```

vs

```
#11 0.860 $ hardhat compile --force
#11 4.335 Warning: unable to recover token list from 1inch
#11 4.646 Downloading compiler 0.7.6
#11 5.211 $ tsc && tsc -p tsconfig.lib.esm.json && tsc -p tsconfig.lib.commonjs.json
```

The latter doesn't seem to compile any artefacts. According to
NomicFoundation/hardhat#3877 this is due to a
URL parser behavior change in Node 18.16 that can lead to silent
Download failures. It's still no entirely clear to me why it sometimes
works (maybe because of some intermittent error)

### Test Plan

I hope this works, or at least tells us why the files are not being
compiled
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:blocked Blocked by other issues or external reasons type:bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants