Skip to content

Deferred (Lazy) section cache key ignores URL search params: stale grid on client-side navigation with ?sort/?filter #636

Open

Description

@JonasJesus42

In @decocms/tanstack, DecoPageRenderer.tsx builds the deferred-section cache key as:

const stableKey = `${pagePath}::${deferred.component}::${deferred.index}::${deferred.propsHash ?? ""}`;

pagePath has no query string, and propsHash is djb2Hex(JSON.stringify(rawProps)) computed from the raw CMS props (packages/blocks/src/cms/resolve.ts). Props that reference a loader (for example { "__resolveType": "PLP Loader" }) hash identically for every query string.

Repro

  1. Wrap a search/listing section in website/sections/Rendering/Lazy.tsx on a page whose loader reads ?sort_by= or ?filter.*.
  2. Load /category, then client-side navigate to /category?sort_by=price:asc (sort, filter, pager, or browser back).
  3. The route loader refetches with the new params, but the deferred section is served from the cache entry of the first render, so the grid stays stale.

Expected: the key varies with the search params the loader depends on (or the cache is invalidated when the search string changes).

Workaround: unwrap the section from Lazy so it renders eagerly from the route loader (deco-sites/reserva-nuvemshop#97).

Suggested fix: include location.search (or a hash of the resolved props) in stableKey.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions