facebook/react · error · Error

393

393

Error message

Cache cannot be refreshed during server rendering.

What it means

In the SSR renderer, useCacheRefresh() returns unsupportedRefresh — a function that always throws (error code 393). Server rendering has no client cache to invalidate, so the refresh capability does not exist during a Fizz render.

Source

Thrown at packages/react-server/src/ReactFizzHooks.js:861

  const index = thenableIndexCounter;
  thenableIndexCounter += 1;
  if (thenableState === null) {
    thenableState = createThenableState();
  }
  return trackUsedThenable(thenableState, thenable, index);
}

export function readPreviousThenableFromState<T>(): T | void {
  const index = thenableIndexCounter;
  thenableIndexCounter += 1;
  if (thenableState === null) {
    return undefined;
  }
  return readPreviousThenable(thenableState, index);
}

function unsupportedRefresh() {
  throw new Error('Cache cannot be refreshed during server rendering.');
}

function useCacheRefresh(): <T>(?() => T, ?T) => void {
  return unsupportedRefresh;
}

function useMemoCache(size: number): Array<mixed> {
  const data = new Array<any>(size);
  for (let i = 0; i < size; i++) {
    data[i] = REACT_MEMO_CACHE_SENTINEL;
  }
  return data;
}

function clientHookNotSupported() {
  throw new Error(
    'Cannot use state or effect Hooks in renderToHTML because ' +
      'this component will never be hydrated.',

View on GitHub (pinned to eafeac097b)

Solutions

  1. Trigger cache refreshes only from client-side event handlers or transitions
  2. Split the refreshing logic into a 'use client' component and keep the server component read-only
  3. On the server, obtain fresh data per request with fetch()/cache() instead of refreshing

Example fix

// before
function List({items}) {
  const refresh = useCacheRefresh();
  if (items.stale) refresh(); // called during SSR -> throws
  return <ul>...</ul>;
}

// after
// server component stays read-only; refresh lives in a client child
function List({items}) {
  return (<ul>...<RefreshButton /></ul>);
}
// RefreshButton.js
// 'use client'
// const refresh = useCacheRefresh();
// <button onClick={() => refresh()}>Refresh</button>
Defensive patterns

Strategy: type-guard

Prevention

When it happens

Trigger: Calling the refresh function returned by useCacheRefresh() while server rendering: invoking it during render, from a server-executed callback, or from shared code that runs in the SSR pass.

Common situations: Porting client cache-refresh patterns into components that also render on the server; SSR test suites exercising refresh handlers; React 19 cache() adoption where refresh logic sits next to render code.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/388559521e21d45e. Report an issue: GitHub.