Skip to content

Fix ENOTEMPTY error in build-schemas.ts during directory cleanup#523

Merged
hotlong merged 2 commits into
mainfrom
copilot/add-logging-functionality
Feb 5, 2026
Merged

Fix ENOTEMPTY error in build-schemas.ts during directory cleanup#523
hotlong merged 2 commits into
mainfrom
copilot/add-logging-functionality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 5, 2026

CI builds were failing when build-schemas.ts attempted to clean the output directory:

ENOTEMPTY: directory not empty, rmdir '.../json-schema/integration'

Changes

Added retry logic to fs.rmSync() to handle filesystem timing issues:

// Before
fs.rmSync(OUT_DIR, { recursive: true, force: true });

// After  
fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });

The maxRetries and retryDelay options handle race conditions that can occur during recursive directory deletion on some filesystems.

Original prompt

引用: https://github.com/objectstack-ai/spec/actions/runs/21706243682/job/62598002933#step:8:1


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Error Error Feb 5, 2026 10:02am

Request Review

Add maxRetries and retryDelay options to fs.rmSync() call in build-schemas.ts
to handle race conditions that can occur during directory cleanup. This fixes
the ENOTEMPTY error that was causing CI builds to fail.

Resolves: https://github.com/objectstack-ai/spec/actions/runs/21706243682

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add logging functionality for better traceability Fix ENOTEMPTY error in build-schemas.ts during directory cleanup Feb 5, 2026
Copilot AI requested a review from hotlong February 5, 2026 09:59
@hotlong hotlong marked this pull request as ready for review February 5, 2026 10:04
Copilot AI review requested due to automatic review settings February 5, 2026 10:04
@hotlong hotlong merged commit 2ec860f into main Feb 5, 2026
13 of 15 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses ENOTEMPTY filesystem errors occurring in CI builds during directory cleanup by adding retry logic to the fs.rmSync() call in the schema generation script.

Changes:

  • Added maxRetries: 3 and retryDelay: 100 parameters to fs.rmSync() in build-schemas.ts to handle filesystem timing issues during recursive directory deletion

if (fs.existsSync(OUT_DIR)) {
console.log(`Cleaning output directory: ${OUT_DIR}`);
fs.rmSync(OUT_DIR, { recursive: true, force: true });
fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The same ENOTEMPTY error could occur in build-docs.ts which also uses recursive directory removal. Consider applying the same retry logic to the rmSync call on line 246 of build-docs.ts for consistency and to prevent similar CI failures.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants