Calling getEntries right after a webook publish event doesn't always fetch the updated content
See original GitHub issue- Node Version: 8.11.1
- Npm Version: 5.6.0
- Platform: MacOS 10.13.4
- Package Version: 6.1.0
I’m using the webhook system to know when an entry has been published in my space. The webhook works fine and I’m getting the event on my server. But then, when I get the event, I’m calling getEntries
to fetch the data related to my entry and all the links, and most of the time, the data I get is the old data, not the new one.
I’ve found out that if I wait at least 20 seconds before calling getEntries
, it will work fine and I’ll receive my updated data.
Any reason why calling getEntries
when receiving the webhook result in out of date data?
The issue is particularly present when, on the webhook event, I need to fetch the parents entries (using links_to_entry
, and finally calling getEntries
on the final entries id. So the flow might be like this:
- Receive webhook publish event
- Calling
getEntries
withlinks_to_entry
equals to the webhook entry id. - Potentially calling 2) multiple times
- Once I have the entries I need, I’m calling
getEntries
again, but this time withinclude
andsys.id
set to what I need. - Notice that the result of 4) is not the updated content, but the old one. [Unless I wait 20 seconds before doing 4)]
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Won’t start a long discussion here, but @tleunen the method I described works for us with immediate updates, so no waiting for a sync. The downside is that we end up essentially maintaining a content cache (a microservice that does a full sync on boot and then incremental updates), but it lets us do our own tricks with how we resolve content for our UIs while still being able to use contentful’s tools for managing it.
@ilkka Do you mean that the sync api doesn’t have the same limitations than the delivery api (waiting x seconds for the changes to be propagated)?