Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race-condition when call ready() after getAllIt() #8

Closed
huan opened this issue Aug 15, 2019 · 1 comment
Closed

Race-condition when call ready() after getAllIt() #8

huan opened this issue Aug 15, 2019 · 1 comment

Comments

@huan
Copy link
Contributor

huan commented Aug 15, 2019

The following code will demonstrate how to hang node.js by calling close() after getAllIt()

#!/usr/bin/env ts-node

import {
  SnapDB,
}               from 'snap-db'

async function main () {
  const db = new SnapDB({
    dir: '/tmp/xx',
    key: 'string',
  })
  // await db.ready()
  const iterator = await db.getAllIt()
  for await (const i of iterator) {
    console.info(i)
  }
  console.info('before ready()')
  await db.ready()
  console.info('after ready()')
  await db.close()
}

main()

Output:

$ ./t.ts 
before ready()
^C
only-cliches pushed a commit that referenced this issue Aug 16, 2019
@only-cliches
Copy link
Owner

1.1.3 has been released on NPM and resolves this issue. Feel free to comment if you find anything further!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants