Skip to content

fix(campaigns): remove server prefetch causing refetch loop on every navigation - #33

Open
Rishavraaj wants to merge 1 commit into
mainfrom
fix/campaigns-page-refetch-loop
Open

fix(campaigns): remove server prefetch causing refetch loop on every navigation#33
Rishavraaj wants to merge 1 commit into
mainfrom
fix/campaigns-page-refetch-loop

Conversation

@Rishavraaj

Copy link
Copy Markdown
Member

Summary

  • Removes force-dynamic and server-side prefetchInfiniteQuery from the campaigns list page
  • Client now manages all data fetching via useInfiniteQuery with staleTime: 5min

Root Cause

force-dynamic made the server component re-run on every client-side navigation (not just hard refresh). On each visit:

  1. Server prefetched only page 1 from Apollo MCP
  2. HydrationBoundary overwrote the client's multi-page cache with just page 1
  3. IntersectionObserver cascade re-fetched all pages from scratch — again

This caused repeated Apollo API calls every time the user navigated to /campaigns.

Changes

  • apps/web/src/app/(app)/campaigns/page.tsx — removed force-dynamic, server prefetch, and HydrationBoundary; page is now a simple client-rendered component

Test plan

  • Navigate to /campaigns — sequences load (cascade fetches all pages once)
  • Navigate away and back — no new API calls to /api/integrations/apollo/sequences (client cache used)
  • Hard refresh (F5) — sequences re-fetch once (expected, cache cleared)
  • Search in campaigns — filters correctly

🤖 Generated with Claude Code

…navigation

force-dynamic made the server component re-run on every client-side
navigation. The server only prefetched page 1, HydrationBoundary then
overwrote the client's multi-page cache, and the IntersectionObserver
cascade re-fetched all pages again — every navigation.

Client now manages all fetching via useInfiniteQuery with staleTime: 5min.
First visit cascades pages; subsequent visits within 5 min use the cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant