Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

update abstract-leveldown to v4 #28

Merged
merged 9 commits into from
Jan 28, 2018
Merged

Conversation

ralphtheninja
Copy link
Member

No description provided.

@ralphtheninja ralphtheninja self-assigned this Jan 21, 2018
@ralphtheninja
Copy link
Member Author

@vweevers Seems we get some EPERM errors on AppVeyor. These are the errors we got on leveldown as well right? I suspect rocksdb has inherited some errors from leveldown test code that doesn't properly shut down the db.

})

test('tearDown', function (t) {
db.close(testCommon.tearDown.bind(null, 2))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't ask. I think my fingers thought I was typing JSON.stringify with an indentation of 2 👼

@ralphtheninja
Copy link
Member Author

Hmm, there's something fishy here with the destroy-test. After I updated fs.existsSync(location) we get an error on windows only.

test-destroy-rocksdb

@ralphtheninja
Copy link
Member Author

Oooooo k. So maybe we do actually have a bug in the code on windows that we haven't noticed until now. Anyone on windows that would like to take a stab? 😀

@@ -57,7 +57,7 @@ makeTest('test destroy() cleans and removes leveldb-only dir', function (db, t,
db.close(function (err) {
t.notOk(err, 'no error')
leveldown.destroy(location, function () {
t.notOk(fs.existsSync(), 'directory completely removed')
t.notOk(fs.existsSync(location), 'directory completely removed')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's a timing issue to use fs.existsSync() on windows or if it's actually a bug. Clearly, not using location is incorrect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I almost never use fs.exist(Sync), I'm not aware of any timing issues.

It could be the same issue as in leveldown, that some test isn't closing its db, but in leveldown, we saw EBUSY rather than EPERM errors.

No promises as to when, but I'll try to take a look at this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, should have read the code, it actually does close the db. Hmm that's great

Copy link
Member

@vweevers vweevers Jan 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Able to reproduce. There are no leftover files, but it seems the directory itself (location) isn't removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe the test should actually check for an empty folder, rather than the folder itself being removed?

Copy link
Member

@vweevers vweevers Jan 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worse.. leveldown.destroy actually creates the directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repro:

test('destroy does not create a directory', function (t) {
  t.plan(3)

  const location = path.resolve('destroy-test')

  rimraf.sync(location)
  t.is(fs.existsSync(location), false, 'exists before')

  leveldown.destroy(location, function (err) {
    t.ifError(err, 'no error')
    t.is(fs.existsSync(location), false, 'exists after') // Fails
  })
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test could check for

  • removal of the location folder
  • if the folder is not removed, then make sure it's empty

For now, we could do:

fs.readdir(location, (err, files) => {
  if (err && err.code === 'ENOENT') // Passed
  if (files.length === 0) // Passed
})

And open an issue to fix the destroy bug later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #30 for the bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worse.. leveldown.destroy actually creates the directory.

O.o

@ralphtheninja
Copy link
Member Author

@vweevers So we can merge this for now and take care of the other bug separately.

@vweevers
Copy link
Member

@ralphtheninja sure

@ralphtheninja ralphtheninja merged commit fc844eb into master Jan 28, 2018
@ralphtheninja ralphtheninja deleted the abstract-leveldown-v4 branch January 28, 2018 18:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants