Skip to content

Conversation

@TonyCasey
Copy link

It took me a few hours to fix these issues and get it running locally on windows.

  • Restrict local file uploads, downloads, and deletions to server-side execution only.
  • Update webpack configuration to prevent bundling server-only modules in the client.
  • Extend dependencies with necessary libraries (e.g., chalk, lodash, nanoid, etc.).
  • Adjust scripts, packages, and serverExternalPackages in project configuration.
  • Optimize runtime setup for server-side uploads directory.

Summary

Brief description of what this PR does and why.

Fixes #(issue)

Type of Change

  • [ X] Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

How has this been tested? What should reviewers focus on?

Checklist

  • [X ] Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

… local storage operations.

- Restrict local file uploads, downloads, and deletions to server-side execution only.
- Update webpack configuration to prevent bundling server-only modules in the client.
- Extend dependencies with necessary libraries (e.g., `chalk`, `lodash`, `nanoid`, etc.).
- Adjust scripts, packages, and `serverExternalPackages` in project configuration.
- Optimize runtime setup for server-side uploads directory.
@vercel
Copy link

vercel bot commented Oct 30, 2025

@web-flow is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

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

Greptile Summary

This PR addresses Windows compatibility issues that were preventing local development by implementing proper client/server code separation and webpack bundling fixes. The changes prevent Node.js server-only modules from being bundled in client-side code, which was causing build failures on Windows. Key fixes include adding webpack fallback configurations to exclude Node.js built-in modules from client bundles, implementing runtime guards to restrict file operations to server-side execution only, and switching from dynamic imports to synchronous require() calls for better bundling control. The PR also adds missing dependencies and removes the --turbo flag from the dev script to improve Windows compatibility.

PR Description Notes:

  • Missing issue number reference after "Fixes #(issue)"
  • Testing section is incomplete
  • Tests checkbox is unchecked despite being a bug fix

Important Files Changed

Filename Score Overview
apps/sim/next.config.ts 4/5 Added webpack configuration to prevent client bundling of Node.js modules and extended serverExternalPackages for cloud storage SDKs
apps/sim/lib/uploads/core/storage-client.ts 4/5 Implemented server-side-only guards for file operations and switched to synchronous require() calls
apps/sim/lib/uploads/core/setup.server.ts 4/5 Added dynamic module loading and client-side guards to prevent server-only code execution in browsers
apps/sim/package.json 5/5 Added missing dependencies and removed problematic --turbo flag from dev script

Confidence score: 4/5

  • This PR addresses legitimate Windows compatibility issues and implements proper client/server separation patterns
  • Score reflects solid technical approach but lacks comprehensive testing documentation and has some implementation complexity with dynamic requires
  • Pay close attention to the webpack configuration and server-side guards implementation to ensure they don't break existing functionality on other platforms

Sequence Diagram

sequenceDiagram
    participant User
    participant App as "App (Client)"
    participant Server as "Server Runtime"
    participant Webpack as "Webpack Bundler"
    participant FS as "File System"
    participant Storage as "Storage Provider"

    User->>App: "Start application on Windows"
    App->>Webpack: "Bundle client code"
    
    Note over Webpack: Server-only modules excluded from client bundle
    Webpack->>Webpack: "Apply fallbacks for server modules (fs, path, etc.)"
    Webpack-->>App: "Client bundle created (no server modules)"
    
    App->>Server: "Initialize server"
    Server->>Server: "Check if running in browser (window check)"
    
    alt Server Environment
        Server->>FS: "Require Node.js modules (path, fs)"
        FS-->>Server: "Modules loaded successfully"
        Server->>Server: "Set UPLOAD_DIR_SERVER path"
        Server->>Server: "Check storage provider configuration"
        
        alt Local Storage Mode
            Server->>FS: "Create uploads directory"
            FS-->>Server: "Directory created/verified"
        else Cloud Storage (S3/Blob)
            Server->>Storage: "Verify credentials"
            Storage-->>Server: "Credentials validated"
        end
        
        Server-->>App: "Server initialized successfully"
    else Client Environment
        Server->>Server: "Skip server-only operations"
        Server-->>App: "Client-side initialization complete"
    end
    
    App-->>User: "Application ready on Windows"
Loading

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +33 to +36
if (typeof window !== 'undefined' || !UPLOAD_DIR_SERVER) {
// Skip on client side
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The !UPLOAD_DIR_SERVER check might be redundant since UPLOAD_DIR_SERVER is only undefined when typeof window !== 'undefined'. Is there a scenario where UPLOAD_DIR_SERVER could be undefined on the server side?

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/uploads/core/setup.server.ts
Line: 33:36

Comment:
**logic:** The `!UPLOAD_DIR_SERVER` check might be redundant since `UPLOAD_DIR_SERVER` is only undefined when `typeof window !== 'undefined'`. Is there a scenario where UPLOAD_DIR_SERVER could be undefined on the server side?

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@sundaram2021 sundaram2021 left a comment

Choose a reason for hiding this comment

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

please add this module @react-email/render .
But still build fails, becuase of --turbopack.
its a turbopack issue which got fixed link
but since we are using 15.4.1 version of next it still fails , have to upgrade next to canary releases ....
btw if we remove --turbopack then it builds successfully .

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.

3 participants