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

Element cannot be closed / shutdown cleanly #420

Open
OR13 opened this issue Jun 12, 2022 · 6 comments
Open

Element cannot be closed / shutdown cleanly #420

OR13 opened this issue Jun 12, 2022 · 6 comments

Comments

@OR13
Copy link
Sponsor Member

OR13 commented Jun 12, 2022

In order for jest to exit properly, element needs to close all its activity properly.

This is not happening leading to the default jest warning:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
@thomas-tran
Copy link

I got the same issues when implement on azure database ledger since the connection of the database is still open and there is no method from the did method core to close the connection or terminate the ledger for the shutdown method

@OR13
Copy link
Sponsor Member Author

OR13 commented Sep 14, 2022

yes, I have struggled to exit the processes cleanly... perhaps explicit process.exit(0) is needed.

@OR13
Copy link
Sponsor Member Author

OR13 commented Sep 14, 2022

can you link to your source?

@thomas-tran
Copy link

In the Azure SQL database ledger implement, I can close the database connection after the test script https://github.com/sekuid/sidetree.js/blob/main/packages/ledger-ms-sqldb/src/__tests__/AzureSqlDbLedger.test.ts

However, in the did method , I could not do it as there is no method to terminate the ledger properly as the database connection pool is still open. This is not an issue with the actual system as the backend service is support to reuse the connection from the connection pool. However, it will cause an issue during testing or shutting down the system.
https://github.com/sekuid/sidetree.js/blob/main/packages/did-method-atom/src/test/wallet.test.ts

Note: The did-method-atom is used Azure SQL database with ledger enabled (the test will use Ms SQL Server 2022) and Azure storage as the Content address storage (test will used azurite as a storage emulator)

https://github.com/sekuid/sidetree.js/blob/main/docker-compose.yml

@OR13
Copy link
Sponsor Member Author

OR13 commented Sep 15, 2022

did-method-atom super cool!

So i am hearing we ned to expose a shutdown handler from the did method core package, is that right?

Something in here: https://github.com/transmute-industries/sidetree.js/blob/main/packages/did-method/src/Core.ts#L162

@thomas-tran
Copy link

Yes, any function in the IBlockchain interface to terminate/shutdown the ledger e.g

 await this.versionManager.stop();

 await this.blockchain.stop();

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

2 participants