-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Description
Performance Issue: Unpaginated Database Queries
Severity: MEDIUM
Location: src/main/lib/trpc/routers/files.ts:222-253
Description
File scanning reads entire directory tree without pagination, potentially causing memory spikes on large projects.
Risk
- Large projects (node_modules, .git) could cause memory issues
- No timeout on directory traversal
- Simple 5-second TTL cache may not be sufficient
Current Mitigation
- Traversal depth limit: 15 (good ✓)
- File type filtering (good ✓)
- Basic caching (needs improvement)
Recommendation
1. Add Pagination
interface FileListOptions {
limit?: number
offset?: number
maxFiles?: number // Hard limit
}
// Stop after maxFiles reached
if (results.length >= maxFiles) break2. Add Timeout/Cancellation
const abortController = new AbortController()
const timeout = setTimeout(() => abortController.abort(), 5000)
// Check abort signal during traversal
if (abortController.signal.aborted) break3. Improve Caching Strategy
- LRU cache with size limit
- Invalidate on file system changes (use chokidar)
- Per-directory caching instead of full tree
4. Stream Results
// Instead of returning all at once
for await (const file of walkDirectory()) {
yield file // Stream to client
}Impact
Medium - Affects performance on large codebases, could cause app to freeze.
Labels: performance, database
Metadata
Metadata
Assignees
Labels
No labels