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
Don't use process.exit() #948
Comments
Thanks for opening your first issue in aragonCLI! Someone will circle back soon ⚡ |
The file handles we should definitely be closing... but I'm not super sure how we'll be able to close the web3 connection. I guess we can go to |
The first two file descriptors are integral parts of the node process so they are not a problem. Web3 1.x has indeed a way to close a websocket connection
The problem now is to unify an control the multiple providers that are floating around |
After some research today I found this issues hanging the node process: Web3 providersWeb3 WebSocket providers can be gracefully closed with web3.currentProvider.connection.close() We should uniform having only one initialized Web3 object in a CLI command lifecycle and call Known initializations of Web3 providers:
Really long timeoutsthis line in the @aragon/apm is causing the AragonCLI to never stop. https://github.com/aragon/apm.js/blob/3d818929ce19410ea6a29e12964b19c08312b7a7/src/utils/timeout-promise.js#L6. For reference, this .onFinishCommand(async (resultValue) => {
await this.db.disconnect()
process.exit()
}).argv; |
@dapplion I started working on a branch to have a way to unify web3 initialization on the
I think we can have a similar approach for IPFS. What do you think? I'll try to have a draft PR soon 👍 |
@dapplion if we initialize a toolkit instance with something like |
If we use HTTP(s) there will be no need to close open connections. Since the toolkit should not subscribe to anything WebSockets are not mandatory. |
💥 Proposal
In relation to the current SDK v7 refactor push, the frequent use of
process.exit()
in random parts of the code makes it really difficult to do integration testsAs a good practice, a Node.js app should not rely on
process.exit()
to stop a script. Whatever is holding the event loop alive should be cleaned, if possible.For example
dao apps
is not able to finalize on it's own. The npm package node debuggerwtfnode
states that this 3 items are holding the event loop alive:Proposal:
process.exit(1)
for errors. Throw an error and then handle it at the top yargs level with appropriate styling and debug / verbose settingsprocess.exit(0)
The text was updated successfully, but these errors were encountered: