Skip to content

"published" version status serves stale data #46

@fiddlie-ed

Description

@fiddlie-ed

Describe the issue you're facing

When setting the version key of ISbStoryParams explicitly to "published", the SDK caches responses from some paths and only returns those, even if new data has been published.

When version is not set (and so is published-only implicitly) this issue does not occur and live published data is accessible immediately.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-gwo9au?file=pages%2F%5B%5B...slug%5D%5D.tsx

Steps to reproduce

Put some code like the following in your getStaticPaths(), with fallback as blocking and reasonably short revalidate:

const sbParams: ISbStoryParams = {
  version: preview ? "draft" : "published",
  language: locale,
};

// Fetch page content
const storyblokApi = getStoryblokApi();

const { data: pageData } = await storyblokApi.get(
  `cdn/stories/${slug}`,
  sbParams
);

// Redirect if page is a redirect
if (pageData.story.content.component === 'redirect') {
  return {
    redirect: {
      destination: pageData.story.content.url.cached_url,
      permanent: false,
    },
  };
}

// Fetch global content
const { data: navigationData } = await storyblokApi.get(
  `cdn/stories/_global/navigation`,
  sbParams
);

pageData always seems to return up to date data, however, navigationData only returns the data that was published and live at build time.

If the version key is removed from sbParams, the navigationData is always up to date. Similarly, version set to "draft" also remains up to date with correct draft/unpublished data.

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (28) x64 Intel(R) Core(TM) i7-14700K
    Memory: 4.11 GB / 31.13 GB
    Container: Yes
    Shell: 3.3.1 - /usr/bin/fish
  Binaries:
    Node: 21.6.0 - ~/.nvm/versions/node/v21.6.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.0/bin/npm
  Browsers:
    Chrome: 127.0.6533.72

Used Package Manager

yarn

Error logs (Optional)

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-author[Status] Awaiting further information or action from the issue authorpending-triage[Status] Ticket is pending to be prioritisedreact[Package] `storyblok-react` related issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions