mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 16:14:43 +00:00
fix: address code review findings (critical + high + medium)
Critical: - retryOnBusy: return lastErr after exhausted retries instead of nil High: - Remove debug console.log from use-paired-devices.ts Medium: - ChannelGeneralTab: sync state from instance prop via useEffect - i18n: add MsgCannotRemoveLastWriter key + translations (en/vi/zh) - use-channel-crud: refetch after delete instead of optimistic remove
This commit is contained in:
1 parent
5f5b0c45bd
commit
8b08dec04c
9 files changed
+27
-15
No files matched your search
@@ -14,20 +14,21 @@ import (
|
||||
|
||||
// retryOnBusy retries fn up to 3 times on SQLITE_BUSY errors with 500ms delay.
|
||||
func retryOnBusy(fn func() error) error {
|
||||
var lastErr error
|
||||
for attempt := 0; attempt < 3; attempt++ {
|
||||
err := fn()
|
||||
if err == nil {
|
||||
lastErr = fn()
|
||||
if lastErr == nil {
|
||||
return nil
|
||||
}
|
||||
if !strings.Contains(err.Error(), "SQLITE_BUSY") && !strings.Contains(err.Error(), "database is locked") {
|
||||
return err
|
||||
if !strings.Contains(lastErr.Error(), "SQLITE_BUSY") && !strings.Contains(lastErr.Error(), "database is locked") {
|
||||
return lastErr
|
||||
}
|
||||
if attempt < 2 {
|
||||
slog.Warn("bootstrap: retrying after SQLITE_BUSY", "attempt", attempt+1)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
return nil // unreachable, but satisfies compiler
|
||||
return lastErr
|
||||
}
|
||||
|
||||
// SeedToStore seeds embedded templates into agent_context_files (agent-level).
|
||||
|
||||
Reference in new issue
Block a user