Skip to content

Fix Architecture: Convert getDirSize to Async with Early Exit to Prevent Timeout - #8987

Open
ChetanSenta wants to merge 2 commits into
JhaSourav07:mainfrom
ChetanSenta:fix/architecture-async-dir-size
Open

Fix Architecture: Convert getDirSize to Async with Early Exit to Prevent Timeout#8987
ChetanSenta wants to merge 2 commits into
JhaSourav07:mainfrom
ChetanSenta:fix/architecture-async-dir-size

Conversation

@ChetanSenta

Copy link
Copy Markdown
Contributor

Description

Fixes #8961

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

What this PR does

getDirSize() synchronously walked and stat()'d every file in a
freshly-cloned repository (including full .git history) to check it
against 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 413 response. Converted to async fs.promises, added an
early-exit once the running total is already over the limit (no need
to keep walking a repo that's already confirmed oversized), and
excluded .git from the size total, since it's already excluded from
the actual architecture analysis via IGNORED_DIRS.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally.
  • I have run npm run format and npm run lint locally and resolved all errors.
  • My commits follow the Conventional Commits format.
  • I have made sure that I have only one commit to merge in this PR.

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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.

@retenta-bot

retenta-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

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!

@retenta-bot retenta-bot Bot changed the title fix(architecture): getDirSize is now async with early-exit, reducing risk of timing out before the intended 413 response Fix Architecture: Convert getDirSize to Async with Early Exit to Prevent Timeout Aug 10, 2026
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @ChetanSenta, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

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 passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@github-actions github-actions Bot added the type:bug Something isn't working as expected label Aug 12, 2026
@Aamod007 Aamod007 added mentor:Aamod007 type:performance Code changes that improve performance/speed level:intermediate Moderate complexity tasks quality:exceptional Outstanding contribution with exceptional implementation quality, testing. labels Aug 13, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Hey @ChetanSenta, this pull request has been inactive for 3 days. It will be automatically closed in 2 days if no further activity occurs.

If you are still working on this, please push your latest changes or leave a comment to keep it active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:needs-rebase level:intermediate Moderate complexity tasks mentor:Aamod007 quality:exceptional Outstanding contribution with exceptional implementation quality, testing. status:blocked This PR is blocked due to a failing CI check. type:bug Something isn't working as expected type:performance Code changes that improve performance/speed

Projects

None yet

3 participants