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

Memory-leak if we call db.close() right after new SnapDB() without db.ready() #5

Closed
huan opened this issue Aug 15, 2019 · 2 comments
Closed

Comments

@huan
Copy link
Contributor

huan commented Aug 15, 2019

According to the fix of #2, I believe we also need to put some code inside the close() function.

The following code will demonstrate that the node program will hang.

#!/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()
  await db.close()
  console.info('DB close-ed')
}

main()

If we uncomment the await db.ready() in the code, then everything will ok.

@huan huan changed the title Race-Condition of the new ready() mechanism cause memory-leak Memory-leak if we call db.close() right after new SnapDB() without db.ready() Aug 15, 2019
only-cliches pushed a commit that referenced this issue Aug 15, 2019
@only-cliches
Copy link
Owner

1.1.2 is now live on NPM, this issue has been resolved. Feel free to comment if you find anything further!

@huan
Copy link
Contributor Author

huan commented Aug 15, 2019

Thanks for the fix!

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