dat-node icon indicating copy to clipboard operation
dat-node copied to clipboard

dat.close() should probably also call dat.leave()

Open cblgh opened this issue 6 years ago • 4 comments

I was writing a scraper for Rotonde and seeing massive memory leaks in a short amount of time, this despite calling dat.close(). A friend debugged the cause to the network not being left; adding dat.leave() appears to have solved that issue.

Is this intended behaviour of dat.close()? If that's the case y'all might want to mention dat.leave() in the same paragraph as dat.close() in the readme.

cblgh avatar Oct 20 '17 20:10 cblgh

Hey @cblgh , couldn't reproduce and I added a test. https://github.com/datproject/dat-node/pull/174

It seems like dat.leave() is getting called. I wonder if you can find out what your self.network is here when you run close, just to make sure the code path isn't getting skipped (it seems like if self.network doesn't exist, it will just return out with no message) https://github.com/datproject/dat-node/blob/master/dat.js#L227

okdistribute avatar Oct 20 '17 21:10 okdistribute

+1 to what karissa said while I was typing =)

If you can, run the one with a leak with DEBUG=dat-node to see if its trying to call leave, its possible the mutlicb thing isn't doing what is expected.

joehand avatar Oct 20 '17 21:10 joehand

I have been having a similar, potentially related issue. I haven't been able to reproduce the problem in isolation, but it occurs reliably during the test suite for dat-friend. I've created an issue in that repo with some log details, such as an excerpt of results from DEBUG=* npm test

garbados avatar Dec 24 '17 01:12 garbados

Hmm, thanks. Look likes neither bittorrent-dht or dns-discovery are getting closed. Will look into those!

joehand avatar Dec 28 '17 21:12 joehand