Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

  • feat: use 8-core self-hosted runner for faster Docker builds
  • fix: lazy load large YAML prompt to prevent build memory exhaustion
  • fix(nextjs): add force dynamic for copilot routes to resolve OOM issue

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

Any additional information, configuration or data that might be necessary to reproduce the issue or use the feature.

- 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
@vercel
Copy link

vercel bot commented Jul 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 1:46am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 25, 2025 1:46am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR addresses build performance and memory issues in the Sim Studio Next.js application through three targeted improvements:

Performance Enhancement: The GitHub Actions workflow now uses an 8-core self-hosted runner (ubuntu-latest-8-cores) instead of the standard ubuntu-latest runner. This change specifically targets the Docker build process, which builds three different images (simstudio, migrations, and realtime) in a matrix strategy with multi-platform support (linux/amd64, linux/arm64). The additional CPU cores should significantly reduce build times for these resource-intensive operations.

Memory Optimization: The large YAML workflow prompt (300+ lines) in apps/sim/lib/copilot/prompts.ts has been converted from a static constant (YAML_WORKFLOW_PROMPT) to a lazy-loaded function (getYamlWorkflowPrompt()). This prevents the content from being loaded during Next.js static generation, reducing build-time memory consumption.

Dynamic Route Configuration: Five copilot-related API routes now include export const dynamic = 'force-dynamic' directives:

  • /api/workflows/[id]/autolayout/route.ts
  • /api/tools/get-yaml-structure/route.ts
  • /api/workflows/[id]/yaml/route.ts
  • /api/tools/edit-workflow/route.ts

These routes handle complex operations like YAML parsing, workflow conversion, autolayout algorithms, and database operations. The force-dynamic export prevents Next.js from attempting static optimization of these routes during build time, eliminating out-of-memory (OOM) errors that were occurring during static analysis of the complex workflow processing logic.

The changes work together as a comprehensive solution: the lazy-loaded prompt reduces memory pressure from large static content, the dynamic route exports prevent memory-intensive static analysis, and the enhanced CI runner provides more resources for the build process.

Confidence score: 4/5

• This PR is safe to merge as it addresses legitimate performance and memory issues without changing core functionality
• The changes are well-targeted fixes for specific build and memory problems, with minimal risk of introducing new issues
• All files need attention to verify the 8-core runner is properly configured in the CI environment

6 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 17e493b into staging Jul 25, 2025
4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/add-force-dynamic-exports branch July 25, 2025 01:46
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…dioai#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
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.

2 participants