brainy/src/utils
David Snelling d8ae76ba99 feat(storage): fix critical socket exhaustion during metadata reading
CRITICAL ISSUE FIXED: Service initialization was failing due to socket exhaustion
when reading metadata for 1400+ items during index rebuild

Changes:
- Add batch metadata reading to prevent 2000+ concurrent requests
- Implement strict concurrency control (3 max concurrent requests)
- Add proper yielding between batches to prevent event loop blocking
- Reduce batch sizes during initialization (50 → 25 items per batch)
- Add getMetadataBatch() and getVerbMetadataBatch() methods to S3 storage
- Update StorageAdapter interface with batch methods
- Add production environment auto-detection for smart logging
- Auto-cleanup legacy /index folder during initialization

Socket usage: Reduced from 1400+ concurrent to 3 max concurrent

Expected production result:
- Service initialization will complete successfully
- firehoseServiceInitialized: true
- Data collection will begin normally
- No more socket exhaustion errors (100 socket limit exceeded)

Fixes: #socket-exhaustion
Breaking: None - backward compatible with fallback modes
2025-08-07 11:46:07 -07:00
..
adaptiveBackpressure.ts feat: add automatic adaptive performance optimization for high-volume scenarios 2025-08-07 08:37:15 -07:00
adaptiveSocketManager.ts feat: add automatic adaptive performance optimization for high-volume scenarios 2025-08-07 08:37:15 -07:00
autoConfiguration.ts feat(auto-configuration): implement automatic configuration system for optimal settings 2025-08-03 17:27:01 -07:00
cacheAutoConfig.ts feat(pagination): implement cursor-based pagination and enhance search caching 2025-08-04 14:25:05 -07:00
crypto.ts feat(distributed): add distributed mode with multi-instance coordination 2025-08-04 12:18:58 -07:00
distance.ts feat: add GPU acceleration for embeddings with smart device auto-detection 2025-08-05 20:00:04 -07:00
embedding.ts feat: add GPU acceleration for embeddings with smart device auto-detection 2025-08-05 20:00:04 -07:00
environment.ts feat(storage): fix critical socket exhaustion during metadata reading 2025-08-07 11:46:07 -07:00
fieldNameTracking.ts **feat(search): enhance JSON document search with field-level filtering and prioritization** 2025-08-01 08:27:39 -07:00
index.ts refactor: clean up deprecated functions and unused code 2025-08-05 10:16:05 -07:00
jsonProcessing.ts **feat(search): enhance JSON document search with field-level filtering and prioritization** 2025-08-01 08:27:39 -07:00
logger.ts feat(storage): fix critical socket exhaustion during metadata reading 2025-08-07 11:46:07 -07:00
metadataFilter.ts fix: correct typo in README major updates section 2025-08-06 12:29:32 -07:00
metadataIndex.ts feat(storage): fix critical socket exhaustion during metadata reading 2025-08-07 11:46:07 -07:00
metadataIndexCache.ts feat: v0.49 - Filter discovery API, remove deprecated methods, improve performance 2025-08-06 14:39:33 -07:00
operationUtils.ts **feat: implement robust error-handling and operation utilities for storage adapters** 2025-07-30 11:35:09 -07:00
performanceMonitor.ts feat: add automatic adaptive performance optimization for high-volume scenarios 2025-08-07 08:37:15 -07:00
requestCoalescer.ts fix: implement high-volume optimizations to prevent socket exhaustion 2025-08-07 09:09:43 -07:00
searchCache.ts feat(pagination): implement cursor-based pagination and enhance search caching 2025-08-04 14:25:05 -07:00
statistics.ts **feat(core, storage, tests): add service-level statistics tracking and storage adapter enhancements** 2025-07-24 11:35:52 -07:00
statisticsCollector.ts fix(core): resolve TypeScript compilation errors and test failures 2025-08-04 20:00:38 -07:00
textEncoding.ts fix: resolve test failures and browser environment issues 2025-08-05 19:38:26 -07:00
typeUtils.ts **feat(utils): add type utility functions and examples for runtime type management** 2025-07-31 14:24:16 -07:00
version.ts refactor: clean up deprecated functions and unused code 2025-08-05 10:16:05 -07:00
workerUtils.ts feat(storage): fix critical socket exhaustion during metadata reading 2025-08-07 11:46:07 -07:00
writeBuffer.ts fix(emergency): drastically lower high-volume mode activation thresholds 2025-08-07 09:51:22 -07:00