multileveldown icon indicating copy to clipboard operation
multileveldown copied to clipboard

Immediately unref the `ref` provided to `createRpcStream()`

Open vweevers opened this issue 3 years ago • 1 comments

Copied from https://github.com/Level/party/issues/28#issuecomment-1065596009: we don't initially unref. You must make at least one db operation for the logic to work. So this hangs:

const name = Date.now().toString()

const db1 = party(name)
const db2 = party(name)

await db1.open()
await db2.open()

console.log('opened')

// Comment this out to not make the event loop hang
// await db1.put('a', 'b')
// console.log(await db2.get('a'))

vweevers avatar Mar 11 '22 22:03 vweevers

On second thought, it might make more sense to do this (i.e. deciding the initial unref/reffed state) in level-party.

vweevers avatar Mar 11 '22 22:03 vweevers