The current session open flow will not support passing sessions preload or valueEncoding options.
With this new approach, the storage opening is extracted into a _openCapabilities method that's only called by the first session. All sessions are opened with a _openSession method, which waits on the capabilities opening Promise.
As part of this, I also cleaned up some of the opening flow and added another session test. The session tests were making assumptions about sessions that break parity with normal Hypercore:
session.writable should only be readable after session.ready() resolves
core.session() should not synchronously throw on errors that would typically be thrown in core.ready()
This PR changes those behaviors for consistency.
One final thing: corestore@next has been depending on the postload option, which we didn't think through. A better approach is to have a hidden option _preready for the Corestore use-case, as nobody else should need this feature (it's very opaque).
The current session open flow will not support passing sessions
preload
orvalueEncoding
options.With this new approach, the storage opening is extracted into a
_openCapabilities
method that's only called by the first session. All sessions are opened with a_openSession
method, which waits on the capabilities opening Promise.As part of this, I also cleaned up some of the opening flow and added another session test. The session tests were making assumptions about sessions that break parity with normal Hypercore:
session.writable
should only be readable aftersession.ready()
resolvescore.session()
should not synchronously throw on errors that would typically be thrown incore.ready()
This PR changes those behaviors for consistency.
One final thing: corestore@next has been depending on the
postload
option, which we didn't think through. A better approach is to have a hidden option_preready
for the Corestore use-case, as nobody else should need this feature (it's very opaque).