Skip to content

Commit 592687b

Browse files
committed
fix(web): Skip static generation for publisher/agent pages to fix build timeout
Pages are now rendered on-demand with ISR caching (revalidate=600) instead of being pre-generated at build time. This fixes Render deployment timeouts caused by 1253+ pages taking >60 seconds each to generate.
1 parent 863681c commit 592687b

File tree

4 files changed

+0
-85
lines changed

4 files changed

+0
-85
lines changed

web/src/app/publishers/[id]/agents/[agentId]/[version]/page.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { Badge } from '@/components/ui/badge'
2020
import { Button } from '@/components/ui/button'
2121
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
2222
import { cn } from '@/lib/utils'
23-
import { getCachedAgentsForStaticParams } from '@/server/agents-data'
2423

2524

2625
interface AgentDetailPageProps {
@@ -469,16 +468,4 @@ const AgentDetailPage = async ({ params }: AgentDetailPageProps) => {
469468
// ISR Configuration - revalidate every 10 minutes
470469
export const revalidate = 600
471470

472-
// Generate static params for all agent versions
473-
export async function generateStaticParams(): Promise<
474-
Array<{ id: string; agentId: string; version: string }>
475-
> {
476-
const agents = await getCachedAgentsForStaticParams()
477-
return agents.map((agent) => ({
478-
id: agent.publisher_id,
479-
agentId: agent.id,
480-
version: agent.version,
481-
}))
482-
}
483-
484471
export default AgentDetailPage

web/src/app/publishers/[id]/agents/[agentId]/page.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import * as schema from '@codebuff/internal/db/schema'
44
import { and, desc, eq } from 'drizzle-orm'
55
import { notFound, redirect } from 'next/navigation'
66

7-
import { getCachedAgentsForStaticParams } from '@/server/agents-data'
8-
97
interface AgentRedirectPageProps {
108
params: Promise<{
119
id: string // publisher id
@@ -105,20 +103,4 @@ const AgentRedirectPage = async ({ params }: AgentRedirectPageProps) => {
105103
// ISR Configuration - revalidate every 10 minutes
106104
export const revalidate = 600
107105

108-
// Generate static params for all agents
109-
export async function generateStaticParams(): Promise<
110-
Array<{ id: string; agentId: string }>
111-
> {
112-
const agents = await getCachedAgentsForStaticParams()
113-
// Get unique publisher_id + agent_id combinations
114-
const uniqueAgents = new Map<string, { id: string; agentId: string }>()
115-
for (const agent of agents) {
116-
const key = `${agent.publisher_id}/${agent.id}`
117-
if (!uniqueAgents.has(key)) {
118-
uniqueAgents.set(key, { id: agent.publisher_id, agentId: agent.id })
119-
}
120-
}
121-
return Array.from(uniqueAgents.values())
122-
}
123-
124106
export default AgentRedirectPage

web/src/app/publishers/[id]/page.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { notFound } from 'next/navigation'
1010
import { BackButton } from '@/components/ui/back-button'
1111
import { Badge } from '@/components/ui/badge'
1212
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
13-
import { getCachedAgentsForStaticParams } from '@/server/agents-data'
1413

1514
interface PublisherPageProps {
1615
params: Promise<{
@@ -464,12 +463,4 @@ const PublisherPage = async ({ params }: PublisherPageProps) => {
464463
// ISR Configuration - revalidate every 10 minutes
465464
export const revalidate = 600
466465

467-
// Generate static params for all publishers
468-
export async function generateStaticParams(): Promise<Array<{ id: string }>> {
469-
const agents = await getCachedAgentsForStaticParams()
470-
// Get unique publisher IDs
471-
const publisherIds = [...new Set(agents.map((agent) => agent.publisher_id))]
472-
return publisherIds.map((id) => ({ id }))
473-
}
474-
475466
export default PublisherPage

web/src/server/agents-data.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ export interface SitemapAgentData {
182182
last_used?: string
183183
}
184184

185-
export interface StaticParamsAgentData {
186-
id: string
187-
version: string
188-
publisher_id: string
189-
}
190-
191185
export const fetchAgentsForSitemap = async (): Promise<SitemapAgentData[]> => {
192186
try {
193187
// Fetch only the fields needed for sitemap URLs - no data blob at all
@@ -236,36 +230,6 @@ export const fetchAgentsForSitemap = async (): Promise<SitemapAgentData[]> => {
236230
}
237231
}
238232

239-
export const fetchAgentsForStaticParams = async (): Promise<
240-
StaticParamsAgentData[]
241-
> => {
242-
try {
243-
// Fetch only the fields needed to build static params for versioned agents.
244-
const agents = await db
245-
.select({
246-
id: schema.agentConfig.id,
247-
version: schema.agentConfig.version,
248-
publisher_id: schema.publisher.id,
249-
})
250-
.from(schema.agentConfig)
251-
.innerJoin(
252-
schema.publisher,
253-
eq(schema.agentConfig.publisher_id, schema.publisher.id),
254-
)
255-
.orderBy(sql`${schema.agentConfig.created_at} DESC`)
256-
257-
return agents
258-
} catch (error) {
259-
// In CI/build environments without a database, return empty array
260-
// so pages are dynamically rendered at runtime instead of statically generated
261-
console.warn(
262-
'[fetchAgentsForStaticParams] Database unavailable, returning empty array:',
263-
error instanceof Error ? error.message : error,
264-
)
265-
return []
266-
}
267-
}
268-
269233
export const getCachedAgentsForSitemap = unstable_cache(
270234
fetchAgentsForSitemap,
271235
['agents-sitemap'],
@@ -275,15 +239,6 @@ export const getCachedAgentsForSitemap = unstable_cache(
275239
},
276240
)
277241

278-
export const getCachedAgentsForStaticParams = unstable_cache(
279-
fetchAgentsForStaticParams,
280-
['agents-static-params'],
281-
{
282-
revalidate: 600, // 10 minutes
283-
tags: ['agents', 'static-params'],
284-
},
285-
)
286-
287242
// ============================================================================
288243
// LIGHTWEIGHT STORE DATA - Basic info without metrics for fast initial load
289244
// ============================================================================

0 commit comments

Comments
 (0)