cardamom
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v260View latest version
- Location:
backend/database/queries.ts:199-217
- Issue: DELETE all ingredients then INSERT new ones on every update
- Impact: Data loss risk if INSERT fails, poor performance, breaks referential integrity temporarily
- Fix Options:
- Option A: Use UPSERT pattern with proper diffing
- Option B: Wrap in transaction with proper rollback
- Issue: Multi-table operations aren't wrapped in transactions
- Impact: Partial updates can leave database in inconsistent state
- Example: Recipe creation inserts recipe then ingredients separately - if ingredient insert fails, orphaned recipe remains
- Fix: Wrap all multi-table operations in transactions
- Location: All list queries (recipes, shopping lists)
- Issue: No pagination or limits on query results
- Impact: Memory exhaustion with large datasets, slow response times
- Fix: Implement pagination with default limits (e.g., 50 items per page)
- Location:
backend/database/queries.ts:257-263
- Issue: Using string concatenation for IN clause instead of parameterized queries
- Impact: Potential performance issues with query plan caching
- Fix: Use proper parameterized queries or batch operations
- Issue: Each query creates new connection to SQLite
- Impact: Overhead on each query, especially problematic with N+1 queries
- Fix: Implement connection reuse pattern for Val Town SQLite
- Location:
backend/database/queries.ts:282-320
- Issue: Heavy string processing on every shopping list creation
- Impact: Slow shopping list generation with many recipes
- Fix: Pre-compute normalized names or use database-level normalization