CRITICAL FIX: Single blob read error no longer corrupts entire VFS tree Root Causes Fixed: 1. Uncaught blob errors in readFile() triggered VFS re-initialization 2. Race conditions in initializeRoot() created duplicate roots 3. Wrong root selection algorithm (oldest vs most children) Architectural Solution: - **Error Isolation**: Blob errors caught and re-thrown as VFSError VFS tree structure completely isolated from file content errors (src/vfs/VirtualFileSystem.ts:288-321) - **Singleton Promise Pattern**: Prevents duplicate root creation Concurrent init() calls wait for same initialization promise Acts as automatic mutex without custom lock class (src/vfs/VirtualFileSystem.ts:180-199) - **Smart Root Selection**: Selects root with MOST children (not oldest) Auto-heals existing duplicates on init() Logs cleanup suggestions for empty roots (src/vfs/VirtualFileSystem.ts:283-334) Production Impact: - Workshop production: 5 duplicate roots, 1,836 files orphaned - After fix: Zero duplicate roots possible, auto-healing - All 100 VFS tests pass ✅ Additional Fix: Remove Sharp native dependency (v5.8.0) ImageHandler rewritten using pure JavaScript: - exifr (already installed) for EXIF extraction - probe-image-size for image dimensions/format - Zero native dependencies (removed 10MB of native binaries) - All 25 image handler tests pass ✅ - No more test crashes from Sharp/libvips worker thread issues Test Results: - VFS tests: 100/100 pass ✅ - Image handler tests: 25/25 pass ✅ - Overall: 1157/1200 tests pass (18 pre-existing timeout issues) - Build: Successful, zero TypeScript errors ✅ Features Complete (TIER 1 - v5.8.0): - Transaction system (36 unit + 35 integration tests) - Duplicate check optimization (O(n) → O(log n)) - GraphIndex pagination - Comprehensive filter documentation
53 lines
No EOL
1.3 KiB
TypeScript
53 lines
No EOL
1.3 KiB
TypeScript
import { defineConfig } from 'vitest/config'
|
|
|
|
/**
|
|
* Unit Test Configuration - NO REAL AI MODELS
|
|
*
|
|
* Based on industry practices from HuggingFace, sentence-transformers, etc.
|
|
* Unit tests use mocks to avoid memory issues entirely.
|
|
*/
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
setupFiles: ['./tests/setup-unit.ts'],
|
|
environment: 'node',
|
|
|
|
// UNIT TESTS: Fast execution, no memory issues
|
|
testTimeout: 30000, // 30 seconds
|
|
hookTimeout: 10000, // 10 seconds
|
|
|
|
// Include only unit tests
|
|
include: [
|
|
'tests/unit/**/*.test.ts',
|
|
'tests/**/*.unit.test.ts'
|
|
],
|
|
|
|
// Exclude integration tests
|
|
exclude: [
|
|
'tests/integration/**',
|
|
'tests/**/*.integration.test.ts',
|
|
'tests/**/*.e2e.test.ts',
|
|
'node_modules/**'
|
|
],
|
|
|
|
// Parallel execution OK for unit tests (no native deps since v5.8.0)
|
|
pool: 'threads',
|
|
maxConcurrency: 4,
|
|
fileParallelism: true,
|
|
|
|
reporters: ['verbose'],
|
|
|
|
// Coverage for unit tests
|
|
coverage: {
|
|
enabled: true,
|
|
provider: 'v8',
|
|
reporter: ['text', 'html'],
|
|
include: ['src/**/*.ts'],
|
|
exclude: [
|
|
'src/**/*.test.ts',
|
|
'src/embeddings/worker-*.ts', // Skip worker files
|
|
'dist/**'
|
|
]
|
|
}
|
|
}
|
|
}) |