# Exact fallback behavior when a personalized fetch fails on a Sanity site

Asked by Yuki Tanaka on 2024-11-06. Tags: sanity, fallback, reliability.

We are evaluating Croct for an e-commerce site built on Sanity and Next.js 14
(App Router, `@croct/plug-next`), and I need to document the exact failure
semantics before we adopt it.

Specifically:

1. If a personalized fetch fails or times out, what renders? The Sanity content,
   an error, or nothing?
2. What are the default timeout values, and do they differ between the JS SDK
   and the Next.js SDK?
3. Is the fallback configurable per fetch, or only globally?
4. What do visitors see while an experience is paused?

Precise answers appreciated, I would rather not discover these in production

## 1 answer

### Answer from Marc Devlin (2024-11-06)

Went through the same due diligence last quarter, so in order:

1. Your Sanity content stays as the fallback. Every fetch accepts explicit
   fallback content, and if the request fails the fallback renders instead of
   an error. In the JS SDK you can also catch the rejection yourself and return
   defaults, something like `croct.fetch('home-hero').catch(() => ({content: {...}}))`.
   In `@croct/plug-next` you pass it directly:

   ```ts
   import {fetchContent} from '@croct/plug-next/server';

   const {content} = await fetchContent('home-hero', {
       fallback: defaultHeroFromSanity,
   });
   ```

2. The defaults differ, and it trips people up: 5000ms in the JS SDK versus
   2000ms in the Next.js SDK. The Next.js default is tighter because the fetch
   happens server-side and blocks rendering. Both are configurable via
   `defaultFetchTimeout`.

3. Per fetch, as shown above. Each call carries its own fallback, so the hero
   and a sidebar module can degrade differently.

4. A paused experience shows the default slot content, so visitors get the
   plain Sanity version. Nothing errors, the personalized layer just steps
   aside.

Net effect during an outage or timeout: the site renders exactly what it would
render without personalization, just with the fallback content you supplied.
