Fix critical race conditions in auto-flush feature
Fixed three critical issues identified in code review: 1. Race condition with store access: Added storeMutex and storeActive flag to prevent background flush goroutine from accessing closed store. Background timer now safely checks if store is active before attempting flush operations. 2. Missing auto-flush in import: Added markDirtyAndScheduleFlush() call after import completes, ensuring imported issues sync to JSONL. 3. Timer cleanup: Explicitly set flushTimer to nil after Stop() to prevent resource leaks. Testing confirmed all fixes working: - Debounced flush triggers after 5 seconds of inactivity - Immediate flush on process exit works correctly - Import operations now trigger auto-flush - No race conditions detected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -287,6 +287,9 @@ Behavior:
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule auto-flush after import completes
|
||||
markDirtyAndScheduleFlush()
|
||||
|
||||
// Print summary
|
||||
fmt.Fprintf(os.Stderr, "Import complete: %d created, %d updated", created, updated)
|
||||
if skipped > 0 {
|
||||
|
||||
Reference in New Issue
Block a user