thedotmack/claude-mem · error · Error
Failed to clear logs
Error message
Failed to clear logs: ${response.statusText} What it means
LogsDrawer clears logs by POSTing to /api/logs/clear. If that response is not ok, it throws an Error with response.statusText, surfaced in the drawer's error state. It means the server refused or failed to truncate the log store.
Solutions
- POST to /api/logs/clear manually (curl -X POST) and read the status/body to see the server reason
- Check filesystem write permissions on the log file and free disk space
- Confirm backend version matches the UI (route exists)
- After clearing fails, retry; transient file locks may resolve on a second attempt
Example fix
// before
const response = await fetch('/api/logs/clear', { method: 'POST' });
if (!response.ok) {
throw new Error(`Failed to clear logs: ${response.statusText}`);
}
// after
const response = await fetch('/api/logs/clear', { method: 'POST' });
if (!response.ok) {
const body = await response.text();
throw new Error(`Failed to clear logs: ${response.status} ${body}`);
}
setLogs(''); Defensive patterns
Strategy: try-catch
Validate before calling
const res = await fetch('/api/logs/clear', { method: 'POST' });
if (!res.ok) throw new Error(`clear failed: ${res.status}`); Try / catch
try {
const res = await fetch('/api/logs/clear', { method: 'POST' });
if (!res.ok) throw new Error(`Failed to clear logs: ${res.status} ${await res.text()}`);
setLogs('');
} catch (err) {
showError(err instanceof Error ? err.message : 'Unknown error');
} Prevention
- Ensure the server process has write access to the log file
- Monitor disk space on the host running the viewer
- Keep backend and UI versions in sync so the route exists
- Surface the response body, not just statusText
When it happens
Trigger: POST /api/logs/clear returns non-ok: server error while deleting/truncating the log file, endpoint missing (404), or write permissions denied on the log file.
Common situations: Log file owned by another user/process or read-only mount; viewer running without the clear route (older backend behind newer UI); disk-full conditions during truncation.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/4b820b5182bcc157.
Report an issue: GitHub.
Appendix: source
Thrown at src/ui/viewer/components/LogsModal.tsx:148
} finally {
setIsLoading(false);
}
}, [checkIfAtBottom]);
useEffect(() => {
scrollToBottom();
}, [logs, scrollToBottom]);
const handleClearLogs = useCallback(async () => {
if (!confirm('Are you sure you want to clear all logs?')) {
return;
}
setIsLoading(true);
setError(null);
try {
const response = await fetch('/api/logs/clear', { method: 'POST' });
if (!response.ok) {
throw new Error(`Failed to clear logs: ${response.statusText}`);
}
setLogs('');
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
} finally {
setIsLoading(false);
}
}, []);
const handleMouseDown = useCallback((e: React.MouseEvent) => {
e.preventDefault();
setIsResizing(true);
startYRef.current = e.clientY;
startHeightRef.current = height;
}, [height]);
useEffect(() => {
if (!isResizing) return;View on GitHub (pinned to d8bc9755e7)