Closed JanezStupar closed 8 years ago
Could you provide an example of the code that you use to trigger this behaviour? a runnable example showing the error @ http://paste.pouchdb.com/ would be ideal. The steps you have sound a little wrong, a query should never return in a 409, that is only for writes
Hey! Thanks for prompt response. And sorry for the crappy description of my issue.
Anyways here is the plnkr of the method where things go bad: http://plnkr.co/edit/YVhibH1mvISfIiWCYs9n?p=catalogue
It is not a runnable as extracting the code would be a massive pain in the behind. And since it is very likely that I am doing something wrong which may be obvious to you I am going to defer that a bit (especially as things seem to work for me ATM).
I am going to provide a working sample later on if necessary.
As additional context the project code is very asynchronous and it is quite possible that reads and writes could happen at the same time.
Edit: One more thing - I am using the Chrome PouchDB plugin (Fauxton?) - if that could be a source of the issue, somehow.
Yup it looks like an issue with your code, if you try to db.put({_id: 'foo', _rev: '1-1234'})
if foo
doesnt exist it will fail with a 409 because it failed to match the revision to the existing document, are there deletions happening in your code anywhere? it sounds like either you are trying to write first documents with a rev that you generate which you cant do, or documents are getting deleted / the id is getting confused
Closing as it looks like this isnt a bug, but if you are still having issues feel free to follow up in here
Hey @daleharvey, yes you were correct. I was attempting to delete documents and the _rev provided was stale.
Thanks a lot for your help.
Environment (Node.js/browser/hybrid app/etc.)
Browser, Angular 2 (wrapping promises in Observable.fromPromise).
Browser/platform (Chrome/FF/Safari/Edge/iOS/Android/etc.)
Chrome
Adapter (IndexedDB/WebSQL/LevelDB/etc.)
IndexedDB + worker-pouch, Websql
Server (CouchDB/Cloudant/Couchbase/PouchDB Server/etc.)
PouchDB 5.3.1, 5.4.5
Please describe your issue. Test cases (e.g. JSBin) are very helpful!
My case is similar to this one: https://github.com/pouchdb/pouchdb/issues/2951
I attempt to PUT a document with an _id field populated in which I get a 409 error - although there is a _rev included - if I trigger a get query, I get a 404.
What seems to have helped (for the time being) is turning off auto compaction.
Let me know if I can provide any additional information.