Sanity Studio publishes but queries return outdated content (old _updatedAt)

116 replies
Last updated: Sep 9, 2022
Hi Team,
we are facing an issue that is blocking the production of our corporate website

it's a project involving Sanity Studio + NextJs

it has always worked perfectly

but suddenly we are not able to publish new content (at least from last week)

no errors or warnings are returned by the Studio

Here are the steps to reproduce the issue:

1 - updated a field in a document and published the change

https://files.slack.com/files-pri/T9Y440GN8-F041N6HTDLM/new-content.png 2 - schema is correctly updated

https://files.slack.com/files-pri/T9Y440GN8-F041R5NSVJ6/schema.png 3 - query (in Vision panel) returns an old version of the document without latest changes,
please notice the outdated '_updatedAt' value

https://files.slack.com/files-pri/T9Y440GN8-F041R5Q64H0/query-01.png
https://files.slack.com/files-pri/T9Y440GN8-F041N6LCJ2Z/query-02.png On the NextJs side

4 - query result is the same as in Vision (outdated)

https://files.slack.com/files-pri/T9Y440GN8-F041R5RCZ34/no-preview-mode.png
5 - new content is correctly displayed in Preview Mode only

https://files.slack.com/files-pri/T9Y440GN8-F042ES92Q8G/preview-mode.png
Can you please help us to figure out what's going on and a possible fix?
We have a bunch of resources blocked on this (devs, qa, editors) since days
and it's starting to have a very bad impact on the economic metrics of our company

Thanks!
AI Update

I understand this is a critical production issue. Based on your symptoms, here are the most likely causes and solutions:

Most Likely Cause: API Perspective Configuration

The behavior you're describing—where content appears in preview mode but not in Vision or production queries—strongly suggests a perspective mismatch in your queries.

When you publish a document in Studio, it creates a published version. However, if your queries are using the wrong perspective, they might not be retrieving the published content correctly.

Immediate Diagnostic Steps

1. Check your API version and default perspective

If you recently updated your @sanity/client or API version, this could be the culprit. Note that API version updates require explicit opt-in—projects don't automatically upgrade to new API versions.

2. Verify in Vision

In the Vision tool, explicitly test with different perspectives. Add this to your query parameters:

{"perspective": "published"}

Then try:

{"perspective": "raw"}

Compare the results. If raw shows your updated content but published doesn't, there's an issue with how the document is being published.

3. Check the document ID directly

In Vision, query for both the draft and published versions:

*[_id == "YOUR_DOCUMENT_ID"]

and

*[_id == "drafts.YOUR_DOCUMENT_ID"]

This will show you if both versions exist and their respective _updatedAt timestamps.

Potential Causes & Solutions

1. Content Releases (If You're on Growth Plan or Above)

If your organization is on a Growth or Enterprise plan, someone may have enabled Content Releases. When this feature is active, clicking "Publish" doesn't immediately publish—it adds changes to a release bundle instead.

How to check:

  • Look for a "Releases" section in your Studio navigation
  • If you see an active release containing your changes, you need to publish that release itself

How to fix:

  • Navigate to Releases in Studio
  • Find the active release
  • Publish/apply the entire release

2. CDN or API Caching Issue

While less likely (since Vision queries the API directly), there could be a cache invalidation problem.

How to check:

  • Add ?nocache=true or a random query parameter to your Vision queries
  • Check if the _updatedAt timestamp matches what you see in the document inspector

3. Client Configuration in Next.js

Your Next.js client might be configured with an incorrect perspective or caching settings.

Check your Sanity client setup:

// Make sure your client is configured correctly
const client = createClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  apiVersion: 'your-api-version',
  useCdn: false, // Try setting this to false temporarily
  perspective: 'published', // Explicitly set this
})

For preview mode, you should be using perspective: 'previewDrafts'.

Immediate Action Plan

  1. Check for Content Releases first - This is the most common cause of this exact symptom pattern. Look in your Studio navigation for a "Releases" section.

  2. Verify your API client configuration - Ensure useCdn: false temporarily to rule out CDN issues

  3. Test with explicit perspectives - Use Vision to confirm which perspective returns correct data

  4. Check recent configuration changes - Review any recent updates to sanity.config.ts, sanity.cli.ts, or your Next.js client setup

If Nothing Works

If none of the above resolves the issue:

  1. Check your dataset transaction history to confirm the publish action actually occurred
  2. Contact Sanity support directly through the help chat in your project dashboard—they can check server-side logs
  3. Try creating a completely new test document and publishing it to see if the issue is document-specific or system-wide

The fact that preview mode works correctly is actually good news—it means your data is there and your Studio is functioning. This is almost certainly a configuration or perspective issue rather than data loss or a platform bug.

Show original thread
116 replies
Hello. Please kindly group your messages so we can use a single thread to discuss your situation.
Right now there are 8 different threads, which is pretty fragmented and confusing.
how can I group those?
Send a single message into the thread with all the information you have. :)
🙂
done
is it ok?
Amazing. ❤️
So much better, thank you!
What revalidation system do you have in place?
we use 'getServerSideProps'
no revalidation
I see. Do you set some caching headers perhaps?
nop
it has always worked fine before
suddenly this weird behavior
Do you use the Sanity CDN?
nop
could it be related to some quota limit?
attributes for example?
the documents are very complex in structure
Mmmh, maayyyyhaps? I'm not super sure I must say.
this is the dataset status
no limit warnings anyway ...
Do I understand it correctly: You are not able to see changes published in the studio when querying with Vision? Could you DM me your project ID?
8iokmtkl
correct
Could you double check if you’re editing the same dataset that your frontend is connected to? The examples in your screenshots seem to come from the
test
dataset, but I see you have one called
production
too.
already checked
unfortunatelly it happens with both datasets
I suspect it could be related to some content limit
attributes maybe
because documents are very complex in structure
a lot of fields
but it's just a guess of course
no errors or warnings returned
You’re close, but haven’t hit them. Curious, do you get any error message in the console, or network requests that aren’t 200 in the network pane when publishing?
let me check
these are returned before publishing
but nothing after pushing
Those seem unrelated – what about the network pane?
no 200 errors
only this is weird
Would it be OK if you invited me to your project for a bit? knut@sanity.io
sure
let me connect to a call
will be back to you asap
uhm I can invite you but the studio runs under a vpn
what if I share my screen
and you tell me what to do?
I only need access to try to reproduce the error before I escalate 🙂
don’t need the studio
do you need a specific role?
sent invitation for a viewer
I need write access, so developer would be handy
ok
done
Hm. I’m not able to reproduce it. I can write and update published documents on
test
at least.
So that narrows it down to your studio implementation probably
?
the schema is correctly published
but the query doesn't get the published content
all works fine in preview mode on the frontend
but not the query
what implementation part could determine the issue?
But preview mode fetches the draft version of the document, right?
And the production site only query the published documents, I’d think?
yes but it gets an outdated content
that is actually the issue 🙂
and one thing I don't get is why it stopped working suddenly
without breaking changes in the implementation logic
Hm. What would be an _id or title of a page that you expected to be updated, but isn’t?
homePage
_id
Aight - and I can only see one document in the production dataset that was last edited
"2022-09-08T10:25:41Z"
– can you actually see unpublished edits in the studio that’s newer than this?
"seoTitle": "2222224544444444SEO & METADATA",

are you referring to the test dataset?
ah sorry
just a sec
so
in the schema :
seoTitle:3453535Canary: A complete home security system in a single device. – Canary
_updatedAt:2022-09-08T16:05:43Z
in the vision query and frontend:
"_updatedAt":"2022-09-08T10:25:41Z"
old seoTitle
ah. I think I see it now
give me a hope please!!!! 🙂
Yes, the GROQ query gives a different document revision than the studio.
I’ll escalate this
?
I need to check with the Content Lake team. It seems like something is out of sync here.
so we wait for your feedback?
Yes, we’re looking into it now
thanks!
We have found the issues, and looking into solving it
cool!!!!
Side note: It’s probably not super productive feedback, but I’d look into generalizing the content models a bit more. It seems like you use
_type
for very specific pages and that you have a lot of attributes for presentational concerns (colors etc). These are patterns that drive a lot of attributes, but often can be moved to frontend design systems mapped to simpler values etc. If that makes any sense.
yeah I share your concern ....
Could you test if it works better now?
ure
yep it's working!
what was the issue about???
it seems not working for test dataset
production dataset seems fine
Try the
test
dataset again?
it's working!
Awesome. We’re looking into the core issue, but there was a sync issue. We triggered a manual sync to fix it. We’ll look into why it didn’t happen automatically.
so there's nothing we can do to avoid this kind of issues in the future right?
Correct, this is on our end
so ticket closed right?
or are you still checking?
ah noticed the checkmark now
thank you very much!
have a great weekend!
You too!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?