Sync gateway webhook calls and couchbase view updates

Question from mseshachalam, moved from github:

This is a doubt and I havent seen any documentation on this. I want to know below details.

When a document is changed in couchbase server, it calls a webhook that is given in config. We have observed, if we use the document recieved from webhook and query a view it wont give the proper result because the view is not updated to reflect the current document. Is it the case ? Can we make sure that the webhook for a document is called once all the views that are related to the current document is updated ?

I have tried to use the document that is received from the webhook to query a view with a delay(5 secs). Is there any upper limit to the time takes to update the view to reflect the current document that is sent via webhook ?

I’m assuming here you’re talking about a Couchbase Server view.

The webhook fires after Sync Gateway has issued the write to Couchbase Server. If you’re using version 4.1 or later of Couchbase Server, I believe that setting stale=false on your view query will ensure that you see the document.

@adamf[quote=“adamf, post:2, topic:9627”]
I believe that setting stale=false on your view query will ensure that you see the document.
[/quote]

Correct. The views by default will auto refresh on: 5000 doc updates AND 5 seconds.

Both conditions have to be true for the stale=true to get new updates by itself.