Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Exit process after running a command #1477

Merged
merged 1 commit into from Feb 26, 2020
Merged

Exit process after running a command #1477

merged 1 commit into from Feb 26, 2020

Conversation

spalladino
Copy link
Contributor

@spalladino spalladino commented Feb 19, 2020

Fixes #1469

@spalladino spalladino changed the title Port fix for deploy spec to verify spec Exit process after running a command Feb 19, 2020
@spalladino
Copy link
Contributor Author

I've already cherry-picked this one to release/2.8 to publish a new RC with this fix.

@ylv-io
Copy link
Contributor

ylv-io commented Feb 20, 2020

Nice. I was wonder that was the reason it is missing. I guess there was no reason. Also why it is just a process.exit(0) but not if (!options.dontExitProcess && process.env.NODE_ENV !== 'test') process.exit(0);?

@ylv-io ylv-io self-requested a review February 20, 2020 11:05
Copy link
Contributor

@ylv-io ylv-io left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@spalladino
Copy link
Contributor Author

spalladino commented Feb 20, 2020

Also why it is just a process.exit(0) but not if (!options.dontExitProcess && process.env.NODE_ENV !== 'test') process.exit(0)?

dontExitProcess was used when one action called into another (like create calling into push), which is no longer the case in the new implementation. And the NODE_ENV check is not needed because this code has no tests at all (see #1457).

By the way, I'd like for @frangio to check this PR before merging.

@frangio
Copy link
Contributor

frangio commented Feb 26, 2020

What is the underlying reason why it's necessary to call process.exit? I don't think it's good practice to exit the process like this. There could be pending work in the event queue.

I think someone mentioned once that the problem is in the HD wallet provider. Have we looked into fixing that? Because this is not a problem in CLI, but rather in the user setup, caused by a dependency that they installed and configured (granted, recommended by our documentaiton).

@spalladino
Copy link
Contributor Author

spalladino commented Feb 26, 2020

I don't think it's good practice to exit the process like this. There could be pending work in the event queue.

The bulk of the work is currently awaited in the CLI. But it's true that there could be something else we are not considering which gets aborted.

Because this is not a problem in CLI, but rather in the user setup, caused by a dependency that they installed and configured (granted, recommended by our documentaiton).

While I agree, it is perceived as a problem with the CLI by our users, especially since other CLIs do include the process.exit to handle this provider. I would love to actually build a custom solution (see #1336) which is more lightweight, but it's on the backlog now. In the meantime, we need to provide a built-in solution.

Have we looked into fixing that?

In the hdwallet case, I think the issue is with provider-engine. The hdwallet-provider is built using provider-engine, which requires to be stop()'d once it finishes processing. We could add an action at the end of the CLI that inspects if the current provider implements a stop method, and if so, calls it.

However, we had run into issues with other libraries in the past that also have dangling connections (I think a version of truffle-contracts or web3 was one, which came up again during test-env). All in all, just calling process.exit was the cleanest way to wrap things up and ensure that the process would not hang, regardless of issues with our (or our users') dependencies.

To sum up, I'm fine with not adding this process.exit and fixing this particular case (by adding the stop() call), since we have reduced the number of dependencies we need to deal with within the CLI.

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving regardless of my thoughts above because we have to support this at least for now.

@frangio
Copy link
Contributor

frangio commented Feb 26, 2020

Thanks for explaining @spalladino. I've created an issue to review this situation. #1483

@frangio frangio merged commit 03a2411 into master Feb 26, 2020
@frangio frangio deleted the fix/exit-process branch February 26, 2020 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

npx oz deploy hangs when deploying regular contract to Rinkeby
3 participants