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

vscode /usr/share/code/code --ms-enable-electron-run-as-node hardhat solidity consumes CPUs! #211

Closed
AuroraLantean opened this issue Jul 19, 2022 · 6 comments

Comments

@AuroraLantean
Copy link

AuroraLantean commented Jul 19, 2022

Somehow this plugin consume a lot of CPU time, and I do not know why.
At that time I was not running Hardhat test or developing on Hardhat or Solidity ...
As you see below the top 3 processes are running that plugin.
After disabling that plugin, my CPU activities have been reduced dramatically.
I am running on Linux Mint 20.3
vscode3
please advise. thanks

@kanej
Copy link
Member

kanej commented Jul 19, 2022

@AuroraLantean thanks for the feedback.

To clarify, do you mean that you had a hardhat project open, but where doing no editing on solidity files so why is the plugin consuming so much CPU?

@0xMohandes
Copy link

I am having the same issue with version 0.4.4. I didn't know why when I open vscode ( with a project) it just starts using high cpu and never ends ( without even touching anything). I started disabling all extensions until I found it's from Solidity+Hardhat extension. I downgraded it to 0.4.3 and the issue was resolved.
The changelog for new version (0.4.4) is showing this:

  • Fix to restart validation processes on unexpected exits (#209)

So I suppose it was trying to continue the process that was not completed before last exist. Interestingly there was no such condition for my project. so definitely this new fix has brought a new bug!

@danielattilasimon
Copy link

Same here, constantly high CPU usage when the plugin is enabled and the workspace contains Solidity file(s). No issues when opening a workspace containing no Solidity.

It is turning my MacBook into a vacuum 😆

@kanej
Copy link
Member

kanej commented Jul 20, 2022

Thanks for the reports. I suspect it is getting stuck in a loop while trying to load the hardhat config and restarting. I will put a fix together.

kanej added a commit that referenced this issue Jul 20, 2022
To stop a restart loop on bad hardhat config the hardhat worker has been
enhanced to have a lifecycle.

The backgroun process starts as UNINITIALIZED. On `init` it moves to
`STARTING`. Any unexpected exits during starting moves it to
`INITIALIZATION_ERRORED`. Only an edit to the config file will trigger a
retry from this state.

On initialization completing within the background process, it will send
a `INITIALISATION_COMPLETE` message, that will move the state to
`RUNNING`.

An unexpected exit while `RUNNING` will lead to a restart.

Validation requests to the process if it is not in the running state (so
errored or still starting), leads to a validator error which will be
displayed to the user.

In response to #211.
kanej added a commit that referenced this issue Jul 20, 2022
To stop a restart loop on bad hardhat config the hardhat worker has been
enhanced to have a lifecycle.

The background process starts as UNINITIALIZED. On `init` it moves to
`STARTING`. Any unexpected exits during starting moves it to
`INITIALIZATION_ERRORED`. Only an edit to the config file will trigger a
retry from this state.

On initialization completing within the background process, it will send
a `INITIALISATION_COMPLETE` message, that will move the state to
`RUNNING`.

An unexpected exit while `RUNNING` will lead to a restart.

Validation requests to the process if it is not in the running state (so
errored or still starting), leads to a validator error which will be
displayed to the user.

In response to #211.
kanej added a commit that referenced this issue Jul 21, 2022
To stop a restart loop on bad hardhat config the hardhat worker has been
enhanced to have a lifecycle.

The background process starts as UNINITIALIZED. On `init` it moves to
`STARTING`. Any unexpected exits during starting moves it to
`INITIALIZATION_ERRORED`. Only an edit to the config file will trigger a
retry from this state.

On initialization completing within the background process, it will send
a `INITIALISATION_COMPLETE` message, that will move the state to
`RUNNING`.

An unexpected exit while `RUNNING` will lead to a restart.

Validation requests to the process if it is not in the running state (so
errored or still starting), leads to a validator error which will be
displayed to the user.

In response to #211.
kanej added a commit that referenced this issue Jul 21, 2022
To stop a restart loop on bad hardhat config the hardhat worker has been
enhanced to have a lifecycle.

The background process starts as UNINITIALIZED. On `init` it moves to
`STARTING`. Any unexpected exits during starting moves it to
`INITIALIZATION_ERRORED`. Only an edit to the config file will trigger a
retry from this state.

On initialization completing within the background process, it will send
a `INITIALISATION_COMPLETE` message, that will move the state to
`RUNNING`.

An unexpected exit while `RUNNING` will lead to a restart.

Validation requests to the process if it is not in the running state (so
errored or still starting), leads to a validator error which will be
displayed to the user.

In response to #211.
@kanej
Copy link
Member

kanej commented Jul 21, 2022

@danielattilasimon, @AuroraLantean

We have pushed a fix for high cpu in some cases (specifically a restart loop from bad hardhat configs), can you try version 0.4.5 and see if you still see high cpu?

@danielattilasimon
Copy link

Thank you so much! The issue is fixed on my end 🙏

Interesting that it happens with bad configs. Maybe I should take a closer look at ours 😅

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

5 participants