LWCAdvancedrace-conditionldssave
Handle race condition between wire getRecord and imperative save
Real World Scenario
Users double-click Save; second save overwrites first with stale wire data causing lost field updates intermittently.
Expected Answer
• Disable save button during in-flight save operation
• Optimistic locking with SystemModstamp or custom version field check in Apex
• Merge user edits with latest server state on conflict error
• Do not reinitialize form from wire mid-edit without user consent
• Use lastSavedRecord snapshot for diff not live wire during edit session
• Show conflict resolution UI when concurrent edit detected
• Test two users editing same record simultaneously in UAT
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Direct answer: Disable save button during in-flight save operation Also consider: Optimistic locking with SystemModstamp or custom version field check in Apex In practice: Merge user edits with latest server state on conflict error Optimize for scale and operational observability.
Architect Perspective
Concurrent edit is normal in CRM — LWC forms need explicit conflict strategy not hope.