Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

fix: providers leaking resources on dht construction #194

Merged

Conversation

vasco-santos
Copy link
Member

After debugging one js-ipfs example hanging, I found this leaking issue.

When js-libp2p is created, the dht will be created if enabled. When the dht is enabled, it will be instantiated. During the instantiation, Providers was also instantiated and a setter was starting a timer. If the dht was created, but not started, when a process is closing, this timer was not cleared, since the stop was also not called.

@vasco-santos vasco-santos force-pushed the fix/providers-leaking-resources-on-dht-construction branch from 3602a45 to 0e5f6fd Compare June 4, 2020 22:35
@vasco-santos vasco-santos requested a review from jacobheun June 4, 2020 22:37
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

LGTM, nice find

src/providers.js Outdated
start () {
if (this._cleaner) {
clearInterval(this._cleaner)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The check isn't necessary in stop and start since clearInterval ignores null/undefined values.

@vasco-santos vasco-santos merged commit 59f373a into master Jun 5, 2020
@jacobheun jacobheun deleted the fix/providers-leaking-resources-on-dht-construction branch July 10, 2020 11:22
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.

2 participants