Skip to content

Fix: CI - #16504

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:fix/ci
Jun 30, 2026
Merged

Fix: CI#16504
yuzhichang merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:fix/ci

Conversation

@Lynn-Inf

Copy link
Copy Markdown
Contributor

Summary

Fix race condition in parallel lefthook hooks causing ETXTBSY error

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 30, 2026
@Lynn-Inf Lynn-Inf added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 30, 2026
@Lynn-Inf
Lynn-Inf marked this pull request as draft June 30, 2026 11:54
@Lynn-Inf
Lynn-Inf marked this pull request as ready for review June 30, 2026 11:54
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

lefthook.yml pre-commit hooks for web-prettier and web-eslint are updated to use a mutex directory and conditional npm ci before running formatters/linters. A React import is reordered in modal.tsx.

Changes

Pre-commit Hook Dependency Guards

Layer / File(s) Summary
Mutex + conditional npm ci for web-prettier and web-eslint
lefthook.yml
Both hooks now create /tmp/ragflow-web-npm-lock as a mutex, conditionally run npm ci when web/node_modules/.package-lock.json is absent, then invoke prettier/eslint via cd web + xargs npx on staged files.
React import reorder
web/src/components/ui/modal/modal.tsx
import React moved before cn and Radix/Lucide imports; no logic changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 Before the commit lands with care,
A mutex guards the npm lair,
If node_modules went astray,
npm ci saves the day,
Then prettier hops along — hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic and does not clearly convey the main change. Rename it to a specific summary such as 'Serialize lefthook web installs to prevent ETXTBSY errors'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the template and clearly summarizes the CI race condition fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 30, 2026
@Lynn-Inf
Lynn-Inf marked this pull request as draft June 30, 2026 11:55
@Lynn-Inf
Lynn-Inf marked this pull request as ready for review June 30, 2026 11:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lefthook.yml`:
- Around line 51-58: The mutex handling in the lefthook pre-commit flow is only
cleaned up on the normal path, so the lock directory can be left behind if the
shell exits early. Update the script sections around the web install logic and
the related lock usage to register a trap that always removes the mutex on EXIT,
INT, and TERM, and keep the existing manual cleanup as a fallback. Make sure the
cleanup is tied to the lock variable used in the npm ci guard so both the first
block and the later matching block release the same mutex reliably.

In `@web/src/components/ui/modal/modal.tsx`:
- Around line 1-5: This change touches the off-limits modal component under
src/components/ui/, so revert any import-order edits in modal.tsx and avoid
modifying that file as part of the CI race-condition fix. If modal behavior is
needed, implement the adjustment in a wrapper/composed component outside
src/components/ui/ and keep the existing modal imports unchanged unless explicit
approval is obtained.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bec96d8c-5ef2-4e1c-8248-9f392ce9393a

📥 Commits

Reviewing files that changed from the base of the PR and between 3633d08 and 6652faf.

📒 Files selected for processing (2)
  • lefthook.yml
  • web/src/components/ui/modal/modal.tsx

Comment thread lefthook.yml
Comment on lines +51 to +58
LOCKDIR=/tmp/ragflow-web-npm-lock
while ! mkdir "$LOCKDIR" 2>/dev/null; do sleep 0.5; done
if [ ! -f web/node_modules/.package-lock.json ]; then
echo "==> web/node_modules missing or incomplete; running npm ci --prefix web"
rm -rf web/node_modules
npm ci --prefix web --no-audit --no-fund || { rm -rf "$LOCKDIR"; exit 1; }
fi
rm -rf "$LOCKDIR"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Release the mutex via trap, not only on the happy path.

If the shell exits after Line 52 or Line 66 but before Line 58 or Line 72, /tmp/ragflow-web-npm-lock is left behind and every later pre-commit will spin forever in the while ! mkdir ... loop. This guard needs cleanup on EXIT/INT/TERM, not just manual rm -rf calls.

Suggested fix
         LOCKDIR=/tmp/ragflow-web-npm-lock
+        cleanup_lock() { rmdir "$LOCKDIR" 2>/dev/null || true; }
         while ! mkdir "$LOCKDIR" 2>/dev/null; do sleep 0.5; done
+        trap cleanup_lock EXIT INT TERM
         if [ ! -f web/node_modules/.package-lock.json ]; then
           echo "==> web/node_modules missing or incomplete; running npm ci --prefix web"
           rm -rf web/node_modules
-          npm ci --prefix web --no-audit --no-fund || { rm -rf "$LOCKDIR"; exit 1; }
+          npm ci --prefix web --no-audit --no-fund
         fi
-        rm -rf "$LOCKDIR"
+        cleanup_lock
+        trap - EXIT INT TERM

Also applies to: 65-72

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lefthook.yml` around lines 51 - 58, The mutex handling in the lefthook
pre-commit flow is only cleaned up on the normal path, so the lock directory can
be left behind if the shell exits early. Update the script sections around the
web install logic and the related lock usage to register a trap that always
removes the mutex on EXIT, INT, and TERM, and keep the existing manual cleanup
as a fallback. Make sure the cleanup is tied to the lock variable used in the
npm ci guard so both the first block and the later matching block release the
same mutex reliably.

Comment on lines +1 to 5
// src/components/ui/modal.tsx
import React, { FC, ReactNode, useCallback, useEffect, useMemo } from 'react';
import { cn } from '@/lib/utils';
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { AlertCircle, CheckCircle, Info, Loader, X } from 'lucide-react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Do not modify files under src/components/ui/.

This file is inside src/components/ui/ which is explicitly off-limits for modifications per project path instructions. Changes here require explicit user approval. Additionally, this import reorder appears unrelated to the stated PR objective of fixing the CI race condition in lefthook.yml.

If the import order change is necessary, consider wrapping or composing this component outside src/components/ui/ instead, or seek explicit approval for this modification.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/ui/modal/modal.tsx` around lines 1 - 5, This change
touches the off-limits modal component under src/components/ui/, so revert any
import-order edits in modal.tsx and avoid modifying that file as part of the CI
race-condition fix. If modal behavior is needed, implement the adjustment in a
wrapper/composed component outside src/components/ui/ and keep the existing
modal imports unchanged unless explicit approval is obtained.

Source: Path instructions

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (3633d08) to head (6652faf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16504   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit b53b693 into infiniflow:main Jun 30, 2026
14 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants