Fix Architecture: Convert getDirSize to Async with Early Exit to Prevent Timeout - #8987
Fix Architecture: Convert getDirSize to Async with Early Exit to Prevent Timeout#8987ChetanSenta wants to merge 2 commits into
Conversation
…exclude .git from size total
|
Someone is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request addresses the issue of potential timeouts when calculating directory sizes in large repositories by converting the getDirSize function to use async I/O. This change aligns with previous decisions to optimize performance and prevent blocking operations, as seen in the refactor of getDirSize and traverseDir to use async I/O. Thank you for your contribution, and I look forward to your updates! |
|
🚨 Hey @ChetanSenta, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Aamod007
left a comment
There was a problem hiding this comment.
Excellent architectural fix! Converting \getDirSize\ to be fully asynchronous in
oute.ts\ is crucial for serverless environments to prevent blocking the event loop on large repositories. The early exit condition \if (totalSize > limit)\ is a brilliant optimization that will save significant execution time when users accidentally submit massive repos. Additionally, skipping the .git\ directory entirely is a very smart move since we don't care about git history size for the architecture analysis.
The tests added to
oute.test.ts\ perfectly validate both the .git\ exclusion and the early-exit behavior.
Labels applied:
- type:performance: Greatly optimizes disk I/O and prevents serverless timeouts on large clones.
- level:intermediate: Requires careful handling of recursive async filesystem traversal and short-circuiting.
- quality:exceptional: Clean, efficient code with robust and specific test cases.
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
Description
Fixes #8961
Pillar
What this PR does
getDirSize()synchronously walked andstat()'d every file in afreshly-cloned repository (including full
.githistory) to check itagainst the 500MB limit — for a legitimately large repo, this
synchronous walk itself risks exceeding the serverless function's
execution timeout before the code ever reaches its own intended,
graceful
413response. Converted to asyncfs.promises, added anearly-exit once the running total is already over the limit (no need
to keep walking a repo that's already confirmed oversized), and
excluded
.gitfrom the size total, since it's already excluded fromthe actual architecture analysis via
IGNORED_DIRS.Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run formatandnpm run lintlocally and resolved all errors.