Skip to content

Unhandled Promise Rejection in v0.7.20 #696

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

Closed
barakman opened this issue Feb 16, 2022 · 11 comments
Closed

Unhandled Promise Rejection in v0.7.20 #696

barakman opened this issue Feb 16, 2022 · 11 comments

Comments

@barakman
Copy link

barakman commented Feb 16, 2022

Using:

  • solidity-coverage 0.7.20
  • truffle 5.4.33
  • solc 0.8.12

Executing truffle run coverage results with:

UnhandledRejections detected
Promise {
  <rejected> TypeError: Cannot read private member from an object whose class did not declare it
      at __classPrivateFieldGet (/MyProject/node_modules/ganache/dist/node/webpack:/Ganache/core/lib/src/server.js:10:94)
      at close (/MyProject/node_modules/ganache/dist/node/webpack:/Ganache/core/lib/src/server.js:221:13)
      at /MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:32:6
      at new Promise (<anonymous>)
      at /MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:6:9
      at ret (/MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:56:76)
      at API.finish (/MyProject/node_modules/solidity-coverage/lib/api.js:226:36)
      at Object.finish (/MyProject/node_modules/solidity-coverage/plugins/resources/plugin.utils.js:299:22)
      at plugin (/MyProject/node_modules/solidity-coverage/plugins/truffle.plugin.js:121:15)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
} TypeError: Cannot read private member from an object whose class did not declare it
    at __classPrivateFieldGet (/MyProject/node_modules/ganache/dist/node/webpack:/Ganache/core/lib/src/server.js:10:94)
    at close (/MyProject/node_modules/ganache/dist/node/webpack:/Ganache/core/lib/src/server.js:221:13)
    at /MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:32:6
    at new Promise (<anonymous>)
    at /MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:6:9
    at ret (/MyProject/node_modules/solidity-coverage/node_modules/pify/index.js:56:76)
    at API.finish (/MyProject/node_modules/solidity-coverage/lib/api.js:226:36)
    at Object.finish (/MyProject/node_modules/solidity-coverage/plugins/resources/plugin.utils.js:299:22)
    at plugin (/MyProject/node_modules/solidity-coverage/plugins/truffle.plugin.js:121:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

This problem does not occur when using:

  • solidity-coverage 0.7.18
  • truffle 5.4.32
  • solc 0.8.11
@cgewecke
Copy link
Member

Ah! Could you try installing [email protected] and then in .solcover.js set the client option as below:

module.exports = {
  client: require('ganache-cli')
}

solidity-coverage is not working correctly with ganache v7 (see #694) which is now default in Truffle >= 5.4.30.

As discussed in the issue you opened last week, I've made ganache-cli something the user has to have as an explicit dependency in their own project (rather than something they're incidentally getting from the plugin).

Apologies, I didn't think this would be a breaking change.

@barakman
Copy link
Author

NP, your quick response is well appreciated :)
I followed your instructions, and now I'm getting:

Error: Error: Could not load .solcover.js config file. This can happen if it has a syntax error or the path you specified for it is wrong.Cannot find module 'ganache-cli'
Require stack:
- /MyProject/.solcover.js
- /MyProject/node_modules/solidity-coverage/plugins/resources/plugin.utils.js
- /MyProject/node_modules/solidity-coverage/plugins/truffle.plugin.js
- /MyProject/node_modules/original-require/index.js
- /MyProject/node_modules/truffle/build/cli.bundled.js
    at Object.loadSolcoverJS (/MyProject/node_modules/solidity-coverage/plugins/resources/plugin.utils.js:212:13)
    at plugin (/MyProject/node_modules/solidity-coverage/plugins/truffle.plugin.js:31:25)
    at Object.run (/MyProject/node_modules/truffle/build/webpack:/packages/core/lib/commands/run/runHandler.js:20:1)
    at node:internal/util:360:7
    at new Promise (<anonymous>)
    at bound run (node:internal/util:346:12)
    at Object.module.exports [as run] (/MyProject/node_modules/truffle/build/webpack:/packages/core/lib/commands/run/run.js:18:1)
    at Command.run (/MyProject/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)

@cgewecke
Copy link
Member

@barakman Could you double-check that [email protected] is installed as a separate dependency in your project?

This error:

Cannot find module 'ganache-cli'

... is what I'd expect if it was missing from the outermost layer of your node_modules.

@barakman
Copy link
Author

barakman commented Feb 16, 2022

Oh, it most certainly isn't.
Ever since Truffle has incorporated Ganache as part of its services (no need to run ganache as a separate process, etc), I no longer have it as part of my project dependencies.
Here's what I have in package.json:

    "devDependencies": {
        "decimal.js": "10.3.1",
        "solidity-coverage": "0.7.20",
        "truffle": "5.4.33",
        "web3": "1.7.0"
    }

I would highly prefer to keep it this way, in order to avoid "version collisions" around that area.
To my understanding, part of the idea in incorporating Ganache into Truffle, is that Truffle users no longer need to be "aware of" Ganache in any way (and that includes installation).

@cgewecke
Copy link
Member

@barakman This isn't optional for moment because solidity-coverage has stopped working with the latest version of Truffle. Your near-term choices are:

  • inconsistent ganache versions: install [email protected] and use the client option to load it
  • consistent ganache versions: use Truffle <= 5.4.29 (and don't install ganache-cli)

@barakman
Copy link
Author

So if I wish to avoid adding a Ganache dependency in my project, my options are:

  • Use a non-latest Truffle version
  • Use a non-latest Solidity Coverage version

Got it.

Thank you very much for your support, I appreciate it!

@ehsomma
Copy link

ehsomma commented Mar 25, 2022

I have the same issue with version 0.7.20...but if I run "truffle run coverage" from powershell terminal (windows) it works!. Instead if I run it from wsl (linux) I get the error. Just to add more info.

@barakman
Copy link
Author

barakman commented Sep 7, 2022

Resolved in 0.8.1. Thank you!

@KaiRo-at
Copy link

KaiRo-at commented Feb 9, 2023

Resolved in 0.8.1. Thank you!

How can this be resolved in 0.8.1 when that version apparently doesn't support truffle at all any more?

@barakman
Copy link
Author

barakman commented Feb 10, 2023

@KaiRo-at - well, TBH, I moved to "Truffle-based" Hardhat configuration:

    "devDependencies": {
        "@nomiclabs/hardhat-truffle5": "2.0.7",
        "@nomiclabs/hardhat-web3": "2.0.0",
        "hardhat": "2.12.4"
    }

So that might be the reason why I've considered it resolved in solidity-coverage 0.8.1.

domob1812 added a commit to xaya/democrit-evm that referenced this issue Apr 16, 2023
This updates the package.json file to use explicit versions
(not the latest as well) of truffle and solidity-coverage.  This is
necessary to make the coverage work.

For more context, see the discussion here:
  sc-forks/solidity-coverage#696
domob1812 added a commit to xaya/democrit-evm that referenced this issue Apr 18, 2023
This updates the package.json file to use explicit versions
(not the latest as well) of truffle and solidity-coverage.  This is
necessary to make the coverage work.

For more context, see the discussion here:
  sc-forks/solidity-coverage#696
@cgewecke
Copy link
Member

This is ganache related, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants