Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Oct 8, 2025

@vercel
Copy link

vercel bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Oct 8, 2025 8:07am
sim (staging) Ready Ready Preview Comment Oct 8, 2025 8:07am

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 Overview

Summary

This PR implements two key improvements: fixes to the TypeScript SDK publishing pipeline and database connection optimizations for better performance. The changes modernize the ts-sdk package by transitioning it from CommonJS to ES modules, which involves updating the TypeScript configuration, package.json module type, and Vitest configuration to properly handle module resolution. The database performance improvements reduce connection pool sizes across multiple services - the main database pool is reduced from 30 to 20 connections, the socket server's pool from 15 to 5 connections, and the socket manager's pool maintains 3 connections with adjusted timeouts.

The ts-sdk changes align the entire build pipeline with ES module standards, fixing module resolution issues that were likely preventing successful SDK publishing. The publishing workflow is updated to install dependencies from the repository root rather than the package directory, supporting monorepo workspace management. For database optimizations, the changes implement a coordinated reduction in maximum connections across services while fine-tuning timeout configurations - increasing idle timeouts to 20 seconds (allowing connections to stay pooled longer) while reducing connect timeouts to 10 seconds (failing faster on connection issues). These changes work together to reduce overall database connection pressure while maintaining responsive real-time operations for the socket server components.

Important Files Changed

Changed Files
Filename Score Overview
packages/ts-sdk/package.json 3/5 Adds ES module type declaration which may break consumers expecting CommonJS
packages/ts-sdk/tsconfig.json 4/5 Changes module compilation from CommonJS to ES2020 to align with package configuration
packages/ts-sdk/vitest.config.ts 4/5 Adds module resolution conditions to fix testing with conditional exports
.github/workflows/publish-ts-sdk.yml 4/5 Removes working directory to install dependencies from monorepo root
packages/db/index.ts 4/5 Reduces main database pool from 30 to 20 connections and adjusts timeouts
apps/sim/socket-server/database/operations.ts 5/5 Reduces socket server database pool from 15 to 5 connections with timeout optimization
apps/sim/socket-server/rooms/manager.ts 4/5 Adjusts socket room manager connection timeouts for better responsiveness

Confidence score: 4/5

  • This PR is generally safe to merge with some potential breaking changes in the ts-sdk package
  • Score reflects solid database optimizations but concerns about ES module transition compatibility
  • Pay close attention to ts-sdk package.json exports configuration which may not work correctly with dual format support after ES module transition

Sequence Diagram

sequenceDiagram
    participant User
    participant GitHub
    participant CI as "CI/CD System"
    participant NPM as "NPM Registry"
    participant Docker as "Docker Registry"
    participant DB as "Database"

    User->>GitHub: "Push to staging branch"
    User->>GitHub: "Create PR to main branch"
    User->>GitHub: "Merge PR to main"
    
    GitHub->>CI: "Trigger publish workflow"
    Note over CI: "Check if ts-sdk files changed"
    
    CI->>CI: "Setup Bun & Node.js"
    CI->>CI: "Install dependencies"
    CI->>CI: "Run tests"
    CI->>CI: "Build package"
    CI->>CI: "Get package version"
    CI->>NPM: "Check if version exists"
    
    alt Version doesn't exist
        CI->>NPM: "Publish package"
        CI->>GitHub: "Create GitHub release"
    else Version exists
        CI->>CI: "Log skipped publish"
    end
    
    Note over DB: "Database connections reduced from 20 to 5-3 max connections"
    
    DB-->>Docker: "Improved performance with lower connection limits"
Loading

Additional Comments (2)

  1. .github/workflows/publish-ts-sdk.yml, line 82 (link)

    syntax: GitHub repository URL appears incorrect - should be 'simstudioai/sim' not 'simstudio/sim' based on the repository context

  2. packages/ts-sdk/package.json, line 13 (link)

    logic: Both import and require point to the same file. After adding "type": "module", CommonJS consumers may not be able to require this file. Consider building separate CommonJS and ESM bundles or using a tool like tsup for dual format publishing.

7 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 5d887fd into main Oct 8, 2025
3 of 5 checks passed
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