Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Add close method for bcoin wallet #176

Merged
merged 2 commits into from
Mar 30, 2020
Merged

Add close method for bcoin wallet #176

merged 2 commits into from
Mar 30, 2020

Conversation

luckysori
Copy link
Collaborator

These are a couple of patches that need to be released before comit-network/comit-rs#2330 can be merged in.

luckysori added a commit to comit-network/comit-rs that referenced this pull request Mar 28, 2020
WIP because there's currently a `yalc` local dependency which will be
replaced once comit-network/comit-js-sdk#176
is merged and `comit-js-sdk` is released with its changes.

We ensure that all nodes are stopped and all wallets are closed during
Jest teardown.
Copy link
Member

@bonomat bonomat left a comment

Choose a reason for hiding this comment

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

Good catch with the timeout and the missing close function.
We should probably do this in the examples as well...

I found a small problem though. Let me know if you have a question about this.

src/wallet/bitcoin.ts Outdated Show resolved Hide resolved
src/wallet/bitcoin.ts Outdated Show resolved Hide resolved
@luckysori luckysori added the no-mergify Stop mergify to merge this automatically label Mar 29, 2020
@luckysori luckysori removed the request for review from da-kami March 29, 2020 23:48
Copy link
Member

@bonomat bonomat left a comment

Choose a reason for hiding this comment

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

Awesome :)

Otherwise the handle remains open until the timeout promise resolves,
which can make certain programs hang unexpectedly.
@luckysori luckysori removed the no-mergify Stop mergify to merge this automatically label Mar 30, 2020
@mergify
Copy link
Contributor

mergify bot commented Mar 30, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 30, 2020

Build succeeded

@bors bors bot merged commit 334fbd6 into master Mar 30, 2020
@mergify mergify bot deleted the close-wallet branch March 30, 2020 00:22
bors bot added a commit to comit-network/comit-rs that referenced this pull request Mar 30, 2020
2330: Close all handles during Jest teardown r=bonomat a=luckysori

_Waiting for comit-network/comit-js-sdk#176 to be merged and for those changes to be included in a release of `comit-js-sdk` before we can update the last commit in this PR to use that release instead of a local dependency created via [`yalc`](https://github.com/whitecolor/yalc) (which seems to work **much** better than `yarn link`)._

Fixes #2211.

1. Turns out Jest will hang until every timeout is cleared, so racing against a timeout that is only cleared after it resolves was not good.
2. The proper teardown of the e2e test environment is fully achieved with 3698f3a, after a lot of debugging. Unfortunately, Jest recommends this

```
Consider running Jest with `--detectOpenHandles` to troubleshoot this issue
```

when tests hang after passing, but it just [doesn't seem to do anything](jestjs/jest#9473). I tried using [`leaked-handles`](https://github.com/Raynos/leaked-handles) without success, but finally found [`wtfnode`](https://github.com/myndzi/wtfnode), which identified `bcoin` as the culprit.

---

My OCD was definitely triggered with this one, as a different error got me to investigate how to get rid of `smack-my-jasmine-up`. Turns out removing it did not fix that other error, but I still see it as a win, since depending on such an obscure library is bad.

---

And another bug squashed! No more

```
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
```

errors, by combining cde8e0c and 127a4a2:
 - shutting down the logger during teardown.
 - closing log files after 5 seconds of inactivity, to prevent us from reaching the limit of listeners.

I believe log files can be reopened if something else needs to be logged.

Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
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.

None yet

4 participants