-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Unclear error when trying to use instance after .destroy #4339
Comments
Confirmed with @gr2m that any api methods fail, for instance a .put Also this is only an issue with leveldown and *down based adapters. |
pouchdb/lib/adapters/leveldb/index.js Line 345 in f8c06ac
Doesn't return at all after db.destroy |
|
Awesome work tracking this down! So I definitely think this is more of a documentation issue than a bug in PouchDB. My opinion about the var db = new PouchDB('foo');
return db.destroy().then(function () {
db = new PouchDB('foo');
return db.get('bar');
}); That said, I do see a bug if the promise never even rejects. We should definitely reject if you try to do anything on a destroyed database. |
Oops, commented on the PR but probably more relevant here, tl;dr is as nolan said Yup this has come up before, the behaviour this is testing was never one that we have catered for, it would have sometimes worked (and sometimes not) n the http adapter, I think almost always break in any of the other adapters, when you call db.destroy we generally expect that to be the end of the life of the object, if you need another db handle you need to reopen it. We can wipe out the handle when destroy is called, make it throw an obvious error if someone calls any further functions on it, we could also support this use case (being able to reuse the handle after destroy by making all the constructor stateless. As it stands this isnt really a bug and more an unfriendly error message |
I'm interested in helping improve the error messages. Presumably you would want tests written for this; would |
Yup test.basics would be totally fine for this, thanks for picking this up. Feel free to ask here or in irc / wherever if you need any help getting it implemented |
Glad to find this issue here as I also ran into this problem when trying to clean up the db by using |
@medihack At this point I think we'd prefer just to have an error thrown, instead of hanging. :) No one's had time to look at this recently, but if anyone wants to contribute the fix, they'd be welcome to! |
Fixed in 9549fda |
This seems so odd! Not a big deal but IMHO it warrants a mention in the docs. |
We have a failing test in https://github.com/hoodiehq/pouchdb-hoodie-api after upgrading to 4.0.2: hoodiehq/pouchdb-hoodie-api#78
I could track down the issue to this
It's very odd. The node script ends without either calling neither
.then
or.catch
at the end. How is that even possible?The text was updated successfully, but these errors were encountered: