Closed CPatchane closed 7 years ago
@CPatchane Can you give some background as to why we need to automatically do a find
after the index is created please?
Without context it seems very strange to fire an unexpected request, whose result is discarded. It also breaks here if the _id
field wasn't part of the index. Maybe we can find a better way to solve whatever the problem was 😃
@y-lohse The problem was that at the first usage, when the index is created and returned to the client, it was actually not already available and cause an error on the client saying that the index doesn't exist. It's the case in production when using cozy-collect for the first time. I wanted to add some retries here to avoid this specific case. But I agree that I didn't test for other kind of index and I thought that all index was answering on _id
but I can be wrong.
@CPatchane I can't reproduce the problem you're describing though :/. Here's where I'm creating an index and using it right away. It's also surprising to me because we've been using indexes on photos for a while without problem.
Are you sure this wasn't an issue specific to cozy-collect? Maybe we could move this code to cozy-collect instead of having it here where it impacts every app using indexes, sometimes negatively when _id
isn't part of the index?
I know. This issue can happen only on production due to CouchDB usage (which is different from the local development) and only when you create the index for the very first time. It can be difficult to reproduce, but that could happen sometimes when a new user discover its new cozy. We reproduce it (not always) when we created new test intances on staging/production.
Ugh, ok. In that case, I suggest we do the following:
result
field in the response, which seems to be either create
or existing
, and only do the fetch on creation_id
Do you think this would work?
@y-lohse Completely agree with your points here to improve that parts 👍 That should work for me.
Cool, I'll probably submit a PR later today then :)
Great @y-lohse Thanks 👍
Thanks @CPatchane 🍰