• v3.32.2 27764b8b9f

    dpsifr released this 2025-10-10 02:15:09 +02:00 | 849 commits to main since this release

    Critical Bug Fix: Container Restart Persistence

    This release fixes two critical production bugs affecting serverless/containerized deployments (Cloud Run, Fargate, Lambda).

    Bugs Fixed

    1. brain.find({ where: {...} }) returns empty array after restart
    2. brain.init() returns 0 entities after container restart

    Root Cause

    Count persistence was optimized to save only every 10 operations. If <10 entities were added before container restart, counts were never persisted to storage. After restart: totalNounCount = 0, causing empty query results.

    Impact

    The basic write→restart→read scenario now works correctly for all storage adapters.

    Test Scenario (Now Fixed)

    // Service A: Add 2 entities
    await brain.add({ data: 'Entity 1' })
    await brain.add({ data: 'Entity 2' })
    
    // Container restarts (Cloud Run, Fargate, etc.)
    
    // Service B: Query data
    const stats = await brain.getStats()
    console.log(stats.entities.total) // Was: 0 ❌ | Now: 2 ✅
    
    const results = await brain.find({ where: { status: 'active' }})
    console.log(results.length) // Was: 0 ❌ | Now: 2 ✅
    

    Changes

    • baseStorageAdapter.ts: Persist counts on EVERY operation
    • gcsStorage.ts: Better error handling for count initialization

    Full Changelog: https://github.com/soulcraftlabs/brainy/compare/v3.32.1...v3.32.2

    Downloads