fix: wrap useSearchParams in Suspense to fix production builds#88
fix: wrap useSearchParams in Suspense to fix production builds#88codexstar69 wants to merge 1 commit intogrp06:mainfrom
Conversation
Next.js 14+ requires client components that call useSearchParams() to be wrapped in a <Suspense> boundary for static page generation. Without this, `next build` fails and Studio is forced to run in dev mode — causing ~8x higher memory usage (728MB vs 90MB), multi-second per-request compilation latency, and WebSocket connection timeouts on remote deployments. Fixes grp06#87 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3aa06875d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <Suspense> | ||
| <AgentStoreProvider> | ||
| <AgentStudioPage /> | ||
| </AgentStoreProvider> | ||
| </Suspense> |
There was a problem hiding this comment.
Add an explicit fallback to the root Suspense boundary
Wrapping the entire page in <Suspense> without a fallback means the prerendered output for / can be empty (null) whenever useSearchParams() triggers the CSR bailout, so production users may see a blank screen until the client bundle hydrates (especially on slower devices/networks). This fixes the build error, but it also removes any server-rendered shell at this boundary; provide an explicit fallback (or move the boundary lower) to avoid a blank initial render.
Useful? React with 👍 / 👎.
Summary
<Suspense>to fixnext buildfailure caused byuseSearchParams()without a Suspense boundarySuspenseto React import + wrap the default exportFixes #87
Problem
next buildfails with:This forces Studio to run in dev mode only, which causes:
On a 2 GB VPS, dev mode OOM-kills the gateway. On a 4 GB VPS, it still causes 30+ second load times and WebSocket timeout failures ("Connecting to gateway..." hang).
Fix
export default function Home() { return ( + <Suspense> <AgentStoreProvider> <AgentStudioPage /> </AgentStoreProvider> + </Suspense> ); }Why this works
Since Next.js 14, client components using
useSearchParams()must be inside a<Suspense>boundary so Next.js can statically generate the page shell and defer the search-params-dependent subtree to the client. Without it, the static generation phase throws.Reference: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
Test plan
npm run buildcompletes successfully (was failing before)npm run start(production mode) serves the page correctly?agent=...) still work correctly🤖 Generated with Claude Code