Error fetching content "The provided ref is no longer accessible"

Hi, I'm having this error while fetching documents using a permanent access token, If I generate a new token the fetch works fine

response: {
    type: 'api_validation_error',
    message: 'The provided ref is no longer accessible, it has expired. Master ref is: ZQsdphAAACEA2FjG'
  }
2 Likes

Thanks for sharing your use case @alain00.alvarez.

Indeed, each time you get this type of error, you should use a valid and up-to-date ref when fetching documents using a permanent access token.

Hi,

I am having this exact issue, what exactly is causing this to occur? It actually took me a while to figure out what token was incorrect. Building my site locally works fine, but as soon as it is deployed to Vercel I get the error message?

Thanks

Hey everyone,

We're looking into some issues around caching in Next.js. @alain00.alvarez and @jon1 are you both using the App Router?

Sam

In the meantime, you can see if there's any helpful information here:

Hi @samlittlefair, I am using the app router yes. Thanks for the link to this topic!

Hey, I am also having this issue with Nuxt and Vue when deploying on netlify. Is there any update to this issue?

I feel like I was getting this issue among other strange cache issues. Adding the following to my package.json build script helped with Vercel build issues. Locally, I just nuked the .next folder entirely and ran a build and no issues:

"build": "rm -rf .next/cache/fetch-cache && next build"

Anyone else want to test this?

1 Like

@ngiusti If you're having this issue on Nuxt and Vue, it might be a separate error. Could you open a new thread and post your error message?

Hey everyone,

We have opened a thread on the Next.js GitHub repository. Feel free to upvote and subscribe to follow along:

Sam

Is anyone else still experiencing this? I'm running Next 14.1.3

On occasion I see some “stranger things” related to refs. I just delete my .next folder locally and the issue goes away. Fortunately, I haven’t seen this issue in production in a while though.

Strange. I have it in Production but not locally.

Yes, this issue is mostly occurring in Vercel deployments. The following thread has some suggested fixes:

Good afternoon, my Teach Lead and I managed to solve this problem in nextjs 14.2 using react's "cache" function. For now it is working well in our projects. :cowboy_hat_face:

import { createClient } from '@prismicio/client'
import sm from '../../slicemachine.config.json'

export const client = createClient(
  `https://${sm.repositoryName}.cdn.prismic.io/api/v2`,
)

export const getTimeline = cache(async () => {
  return await client.getSingle('timeline')
})
1 Like

Thank you for sharing your solution Nicole :slight_smile: Although I'm curious as to what happens when you update the 'timeline' type? Can you test this and see if it works correctly?

And welcome to the community!

good morning! I went back to work on the project and got the "Unhandled Runtime Error Error: No documents were returned" error again, I deleted the .next cache folder and it corrected my error, I believe it is due to cache and conflict with other projects, informing which worked normally even without the react cache function after deleting the folder

I thought this might be an issue, and this is why we don't recommend using a cache with Prismic, especially for the main/master ref.