Need to close() and possibly pool hypercore instances
AFAICT, via random-access-file, hypercore opens a file-descriptor for every instance, and doesn't close the FD until .close() is called. We definitely don't want to leak those.
Any time hypercore-archiver's get() method is called (eg in archiver-api's archiveProgress() method) a hypercore instance is created. Thus, another FD is created, and not cleaned up.
Two thoughts on that:
- We need to be sure to clean up all hypercores by .close()ing them
- Should we be pooling hypercore instances instead of creating them with .get() every time?
Alternatively, we could pool random-access-file instances, but in either case we'll still need to .close the hypercores
Archiver-server has a solution we can consider: an LRU cache.
Should we be pooling hypercore instances instead of creating them with .get() every time?
Ya, we could definitely optimize the get to not create them every time. Seems like a LRU cache would be the most straightforward way to implement that.