Description
Multiple setServiceJobs calls happen in sequence within async handlers without guaranteeing order or atomicity, potentially causing state corruption.
Affected File
components/canvas-editor.tsx
Current Behavior
// First update
setServiceJobs(prev => prev.map(j => j.id === jobId ? { ...j, progress: 60 } : j))
// Later update (may race with first)
setServiceJobs(prev => prev.map(j => j.id === jobId ? { ...j, status: "Complete" } : j))
If handleServiceResult is called multiple times rapidly, updates may interleave incorrectly.
Security Impact
- Job status may show incorrect progress
- Completed jobs might appear as still processing
- Could cause UI to become out of sync with actual state
Suggested Fix
Batch updates together or use a reducer pattern.
// Single atomic update with all changes
setServiceJobs(prev => prev.map(j => j.id === jobId ? {
...j,
progress: 100,
status: "Complete",
apiStatus: "COMPLETED",
polling: false
} : j))
Description
Multiple
setServiceJobscalls happen in sequence within async handlers without guaranteeing order or atomicity, potentially causing state corruption.Affected File
components/canvas-editor.tsxCurrent Behavior
If
handleServiceResultis called multiple times rapidly, updates may interleave incorrectly.Security Impact
Suggested Fix
Batch updates together or use a reducer pattern.