github thedotmack/claude-mem v8.5.3

latest releases: v10.5.2, v10.5.1, v10.5.0...
one month ago

🛡️ Error Handling Hardening & Developer Tools

Version 8.5.3 introduces comprehensive error handling improvements that prevent silent failures and reduce debugging time from hours to minutes. This release also adds new developer tools for queue management and log monitoring.


🔴 Critical Error Handling Improvements

The Problem

A single overly-broad try-catch block caused a 10-hour debugging session by silently swallowing errors. This pattern was pervasive throughout the codebase, creating invisible failure modes.

The Solution

Automated Anti-Pattern Detection (scripts/detect-error-handling-antipatterns.ts)

  • Detects 7 categories of error handling anti-patterns
  • Enforces zero-tolerance policy for empty catch blocks
  • Identifies large try-catch blocks (>10 lines) that mask specific errors
  • Flags missing error logging that causes silent failures
  • Supports approved overrides with justification comments
  • Exit code 1 if critical issues detected (enforceable in CI)

New Error Handling Standards (Added to CLAUDE.md)

  • 5-Question Pre-Flight Checklist: Required before writing any try-catch
    1. What SPECIFIC error am I catching?
    2. Show documentation proving this error can occur
    3. Why can't this error be prevented?
    4. What will the catch block DO?
    5. Why shouldn't this error propagate?
  • Forbidden Patterns: Empty catch, catch without logging, large try blocks, promise catch without handlers
  • Allowed Patterns: Specific errors, logged failures, minimal scope, explicit recovery
  • Meta-Rule: Uncertainty triggers research, NOT try-catch

Fixes Applied

Wave 1: Empty Catch Blocks (5 files)

  • import-xml-observations.ts - Log skipped invalid JSON
  • bun-path.ts - Log when bun not in PATH
  • cursor-utils.ts - Log failed registry reads & corrupt MCP config
  • worker-utils.ts - Log failed health checks

Wave 2: Promise Catches on Critical Paths (8 locations)

  • worker-service.ts - Background initialization failures
  • SDKAgent.ts - Session processor errors (2 locations)
  • GeminiAgent.ts - Finalization failures (2 locations)
  • OpenRouterAgent.ts - Finalization failures (2 locations)
  • SessionManager.ts - Generator promise failures

Wave 3: Comprehensive Audit (29 catch blocks)

  • Added logging to 16 catch blocks (UI, servers, worker, routes, services)
  • Documented 13 intentional exceptions with justification comments
  • All patterns now follow error handling guidelines with appropriate log levels

Approved Override System

For justified exceptions (performance-critical paths, expected failures), use:

// [APPROVED OVERRIDE]: Brief technical justification
try {
  // code
} catch {
  // allowed exception
}

Progress: 163 anti-patterns → 26 approved overrides (84% reduction in silent failures)


🗂️ Queue Management Features

New Commands

  • npm run queue:clear - Interactive removal of failed messages
  • npm run queue:clear -- --all - Clear all messages (pending, processing, failed)
  • npm run queue:clear -- --force - Non-interactive mode

HTTP API Endpoints

  • DELETE /api/pending-queue/failed - Remove failed messages
  • DELETE /api/pending-queue/all - Complete queue reset

Failed messages exceed max retry count and remain for debugging. These commands provide clean queue maintenance.


🪵 Developer Console (Chrome DevTools Style)

UI Improvements

  • Bottom drawer console (slides up from bottom-left corner)
  • Draggable resize handle for height adjustment
  • Auto-refresh toggle (2s interval)
  • Clear logs button with confirmation
  • Monospace font (SF Mono/Monaco/Consolas)
  • Minimum height: 150px, adjustable to window height - 100px

API Endpoints

  • GET /api/logs - Fetch last 1000 lines of current day's log
  • DELETE /api/logs - Clear current log file

Logs viewer accessible via floating console button in UI.


📚 Architecture Documentation

Session ID Architecture (docs/SESSION_ID_ARCHITECTURE.md)

  • Comprehensive documentation of 1:1 session mapping guarantees
  • 19 validation tests proving UNIQUE constraints and resume consistency
  • Documents single-transition vulnerability (application-level enforcement)
  • Complete reference for session lifecycle management

📊 Impact Summary

  • Debugging Time: 10 hours → minutes (proper error visibility)
  • Test Coverage: +19 critical architecture validation tests
  • Silent Failures: 84% reduction (163 → 26 approved exceptions)
  • Protection: Automated detection prevents regression
  • Developer UX: Console logs, queue management, comprehensive docs

🔧 Technical Details

Files Changed: 25+ files across error handling, queue management, UI, and documentation

Critical Path Protection
These files now have strict error propagation (no catch-and-continue):

  • SDKAgent.ts
  • GeminiAgent.ts
  • OpenRouterAgent.ts
  • SessionStore.ts
  • worker-service.ts

Build Verification: All changes tested, build successful


Full Changelog: v8.5.2...v8.5.3

Don't miss a new claude-mem release

NewReleases is sending notifications on new releases.