holepunchto / corestore

A simple corestore that wraps a random-access-storage module
https://docs.holepunch.to
MIT License
72 stars 31 forks source link

Early return in replicate's ondiscoverKey if closing #84

Closed HDegroote closed 5 months ago

HDegroote commented 5 months ago

This avoids throwing in some edge cases. For example, when a corestore is closed before a hyperswarm, the ondiscoveryKey callback can still trigger, causing an error like


Error: The corestore is closed
at Corestore.get (.../node_modules/corestore/index.js:376:51)
    at ondiscoverykey (.../node_modules/corestore/index.js:436:27)
    ...
    at ReadableState.update (.../node_modules/streamx/index.js:344:12
...

Closing a corestore before the swarm might also just be undefined behaviour though, in which case: feel free to close