Replies: 1 comment
|
Thanks @Dojdik — great diagnosis, this is fixed in e294b6c. 🙏 Landed as proposed: the 1MB file caps in all three backends (the big win — a 4.5MB minified bundle went from a ~118s synchronous block in ts-morph to an 87ms skip), the Two adjustments after verification: the parse timeout uses tree-sitter's native Verified end-to-end with headless A/B runs against a pre-fix worktree — startup scan, symbol reads, and oversized-file fallback all behave. Thanks again for the detailed report! |
Uh oh!
There was an error while loading. Please reload this page.
Bug Fixes for UI Freeze Issues
This document describes the critical bugs that were causing UI freezes and the fixes applied.
Summary of Changes
1. tree-sitter.ts - File Size Limits and Parse Timeout
Problem:
parser.parse()could block the event loop indefinitely on large filesserializeShape,countNodes,collectHashableNodes) had excessive depth limitsFixes:
parseFile()- files larger than this are skippedparser.parse()in a 5-second timeout usingPromise.race()serializeShape()andcountNodes()collectHashableNodes()MAX_CHILDREN = 50limit to prevent exponential blowup in recursive functionsMAX_RESULTS = 200limit incollectHashableNodes()to cap memory usagefindImports()by wrapping re-export query in try/finally to ensuretree.delete()is always called2. regex.ts - String/Comment Awareness and Size Limits
Problem:
extractBraceScope()counted braces inside strings and comments, causing incorrect scope extractionFixes:
extractBraceScope()to track string state (", ', `) and comment state (// and /* */)findSymbols(),findImports(), andfindExports()3. router.ts - Reduced Timeouts and Directory Scan Limits
Problem:
readdirSyncBFS indetectAllLanguages()andfindProbeFile()could scan thousands of directoriesFixes:
executeWithFallbackTracked()detectAllLanguages()limits:findProbeFile()limits:4. ts-morph.ts - File Size Limits
Problem:
getSourceFile(), allowing very large files to be loaded into memorygetPreEmitDiagnostics()to block for minutesFixes:
getSourceFile()usingstatSync()Impact
These fixes address the root causes of UI freezes:
Testing Recommendations
Test with:
Performance Characteristics
After fixes:
Modified files
All reactions