sim icon indicating copy to clipboard operation
sim copied to clipboard

Fix account creation failures in insecure HTTP contexts

Open devdattatalele opened this issue 4 months ago • 2 comments

Summary

Resolves account creation failures caused by crypto.randomUUID() in insecure HTTP contexts and optimizes Docker resource usage.

Problem Statement

Users reported multiple issues with account creation:

  • "Failed to create account" errors in Docker deployments
  • crypto.randomUUID() failures when accessing via non-localhost IPs
  • Docker demanding 8GB RAM causing system constraints
  • Generic error messages providing no actionable guidance

Solution

UUID Fallback System

  • New lib/uuid.ts utility with context-aware UUID generation
  • Falls back to Math.random() in insecure contexts while preserving security where possible
  • Updated all client-side stores and workflow components

Resource Optimization

  • Reduced Docker memory limits: 8G→4G (main app), 8G→2G (realtime)
  • Added memory reservations for better resource planning

Enhanced Error Handling

  • Improved global error boundary with crypto-specific error detection
  • User-friendly guidance for HTTPS/localhost resolution
  • Comprehensive error logging with context information

Technical Details

  • Security: Math.random() fallback is cryptographically weak but acceptable for UI state management
  • Compatibility: Backward compatible with existing UUID generation
  • Performance: Minimal overhead, fallback only when needed
  • Browser Support: Enhanced compatibility detection for older browsers

Testing

  • Validated UUID generation works in both secure and insecure contexts
  • All UUIDs maintain v4 format compliance
  • Confirmed uniqueness across multiple generations

Files Changed

  • apps/sim/lib/uuid.ts - New UUID utility with fallback support
  • apps/sim/app/global-error.tsx - Enhanced error handling
  • docker-compose.local.yml - Optimized memory configuration
  • Multiple store files - Updated to use secure UUID fallback
  • Workflow components - Migrated to context-aware UUID generation

Fixes #1243

devdattatalele avatar Sep 06 '25 07:09 devdattatalele

@devdattatalele is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 06 '25 07:09 vercel[bot]

Building image from this PR with docker/app.Dockerfile is failing because lint is failing. Can you please fix that.

blokovi avatar Sep 23 '25 06:09 blokovi