Skip to content

Commit 17e493b

Browse files
authored
fix(nextjs): add force dynamic exports for new copilot routes (#784)
* feat: use 8-core self-hosted runner for faster Docker builds * fix: lazy load large YAML prompt to prevent build memory exhaustion - Convert YAML_WORKFLOW_PROMPT from static export to lazy function - Prevents 281-line string literal from being loaded during static generation - Fixes exit code 137 memory exhaustion during Docker builds * fix(nextjs): add force dynamic for copilot routes to resolve OOM issue
1 parent a84c557 commit 17e493b

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
build-and-push:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-latest-8-cores
1111
strategy:
1212
fail-fast: false
1313
matrix:

apps/sim/app/api/tools/edit-workflow/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { copilotCheckpoints, workflow as workflowTable } from '@/db/schema'
1414
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
1515
import { convertYamlToWorkflow, parseWorkflowYaml } from '@/stores/workflows/yaml/importer'
1616

17+
export const dynamic = 'force-dynamic'
18+
1719
const logger = createLogger('EditWorkflowAPI')
1820

1921
export async function POST(request: NextRequest) {

apps/sim/app/api/tools/get-yaml-structure/route.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { type NextRequest, NextResponse } from 'next/server'
2-
import { YAML_WORKFLOW_PROMPT } from '../../../../lib/copilot/prompts'
2+
import { getYamlWorkflowPrompt } from '@/lib/copilot/prompts'
3+
4+
export const dynamic = 'force-dynamic'
35

46
export async function POST(request: NextRequest) {
57
try {
@@ -8,7 +10,7 @@ export async function POST(request: NextRequest) {
810
return NextResponse.json({
911
success: true,
1012
data: {
11-
guide: YAML_WORKFLOW_PROMPT,
13+
guide: getYamlWorkflowPrompt(),
1214
message: 'Complete YAML workflow syntax guide with examples and best practices',
1315
},
1416
})
@@ -17,7 +19,7 @@ export async function POST(request: NextRequest) {
1719
return NextResponse.json(
1820
{
1921
success: false,
20-
error: 'Failed to get YAML structure guide',
22+
error: 'Failed to get YAML structure',
2123
},
2224
{ status: 500 }
2325
)

apps/sim/app/api/workflows/[id]/autolayout/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
import { db } from '@/db'
1313
import { workflow as workflowTable } from '@/db/schema'
1414

15+
export const dynamic = 'force-dynamic'
16+
1517
const logger = createLogger('AutoLayoutAPI')
1618

1719
const AutoLayoutRequestSchema = z.object({

apps/sim/app/api/workflows/[id]/yaml/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { copilotCheckpoints, workflow as workflowTable } from '@/db/schema'
1717
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
1818
import { convertYamlToWorkflow, parseWorkflowYaml } from '@/stores/workflows/yaml/importer'
1919

20+
export const dynamic = 'force-dynamic'
21+
2022
const logger = createLogger('WorkflowYamlAPI')
2123

2224
// Request schema for YAML workflow operations

apps/sim/lib/copilot/prompts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,11 @@ export const TITLE_GENERATION_USER_PROMPT = (userMessage: string) =>
376376
`Generate a concise title for a conversation that starts with this user message: "${userMessage}"\n\nReturn only the title text, nothing else.`
377377

378378
/**
379-
* YAML Workflow Reference Guide
380379
* Comprehensive guide for LLMs on how to write end-to-end YAML workflows correctly
380+
* Lazy loaded to prevent memory issues during static generation
381381
*/
382-
export const YAML_WORKFLOW_PROMPT = `# Comprehensive Guide to Writing End-to-End YAML Workflows in Sim Studio
382+
export const getYamlWorkflowPrompt =
383+
() => `# Comprehensive Guide to Writing End-to-End YAML Workflows in Sim Studio
383384
384385
## Fundamental Structure
385386

0 commit comments

Comments
 (0)