Race condition xảy ra khi nhiều async operations chạy đồng thời và kết quả phụ thuộc vào thứ tự hoàn thành.
Cách xử lý: dùng AbortController hủy requests cũ, track request ID và bỏ qua responses không mới nhất, dùng debounce, hoặc mutex/semaphore pattern.
A race condition occurs when multiple async operations run concurrently and the result depends on which one finishes first.
Solutions: use AbortController to cancel stale requests, track a request ID and discard outdated responses, use debounce, or implement a mutex/semaphore pattern.