Skip to content

fix: lefthook deps serialization - #16969

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/lefthook-deps-serialization
Jul 16, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/lefthook-deps-serialization

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix: lefthook deps serialization

Extract npm ci guard into web-deps job; use native deps for serialization instead of a mkdir mutex that could leave stale locks on interrupted commits. Also use single quotes in echo to work around lefthook v2.1.10 stripping double quotes on Windows.

Extract npm ci guard into web-deps job; use native deps for
serialization instead of a mkdir mutex that could leave stale locks
on interrupted commits. Also use single quotes in echo to work
around lefthook v2.1.10 stripping double quotes on Windows.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lefthook.yml (1)

73-109: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Race condition: deps is not a valid Lefthook job property.

Lefthook does not natively support a deps or depends_on property for jobs. Because the pre-commit hook is configured with parallel: true (line 15), web-deps, web-prettier, and web-eslint will all start executing concurrently.

Since deps will be ignored, web-deps may execute rm -rf web/node_modules at the exact moment web-prettier and web-eslint are attempting to invoke npx, causing the linting and formatting jobs to fail or hang.

To enforce ordering without a file lock, you must group the dependency job and the linting jobs using Lefthook's group and piped: true features.

🔒 Proposed fix to enforce sequential execution

By nesting a parallel group inside a piped group, web-deps runs first, and upon success, web-prettier and web-eslint run in parallel.

-    - name: web-deps
-      glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}"
-      run: |
-        # Ensure web/node_modules is populated. CI runners don't run `npm install`
-        # before lefthook, and `npx` without local node_modules fetches the
-        # latest packages from the registry - which breaks because the pinned
-        # prettier plugins (prettier-plugin-organize-imports,
-        # prettier-plugin-packagejson) aren't auto-resolved and ESLint 10
-        # requires eslint.config.js.
-        # Serialized via lefthook 'deps' from web-prettier/web-eslint instead of
-        # a mkdir mutex, which left stale locks on interrupted commits and
-        # caused subsequent commits to hang forever in 'while ! mkdir'.
-        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
-        fi
-    - name: web-prettier
-      glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}"
-      stage_fixed: true
-      deps: [web-deps]
-      run: |
-        if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then
-          cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx prettier --check --ignore-unknown
-        else
-          cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx prettier --write --ignore-unknown
-        fi
-    - name: web-eslint
-      glob: "web/**/*.{js,jsx,ts,tsx}"
-      stage_fixed: true
-      deps: [web-deps]
-      run: |
-        if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then
-          cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx eslint
-        else
-          cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx eslint --fix
-        fi
+    - name: web-checks
+      group:
+        piped: true
+        jobs:
+          - name: web-deps
+            glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}"
+            run: |
+              # Ensure web/node_modules is populated. CI runners don't run `npm install`
+              # before lefthook, and `npx` without local node_modules fetches the
+              # latest packages from the registry - which breaks because the pinned
+              # prettier plugins (prettier-plugin-organize-imports,
+              # prettier-plugin-packagejson) aren't auto-resolved and ESLint 10
+              # requires eslint.config.js.
+              # Serialized via piped group instead of a mkdir mutex.
+              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
+              fi
+          - name: web-linters
+            group:
+              parallel: true
+              jobs:
+                - name: web-prettier
+                  glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}"
+                  stage_fixed: true
+                  run: |
+                    if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then
+                      cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx prettier --check --ignore-unknown
+                    else
+                      cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx prettier --write --ignore-unknown
+                    fi
+                - name: web-eslint
+                  glob: "web/**/*.{js,jsx,ts,tsx}"
+                  stage_fixed: true
+                  run: |
+                    if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then
+                      cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx eslint
+                    else
+                      cd web && printf '%s\n' {staged_files} | sed 's|^web/||' | xargs npx eslint --fix
+                    fi
🤖 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 73 - 109, Replace the unsupported deps-based
ordering around web-deps, web-prettier, and web-eslint with Lefthook group
configuration using an outer piped group and an inner parallel group. Ensure
web-deps completes successfully before web-prettier and web-eslint start, while
preserving parallel execution between the two linting jobs and their existing
commands.
🤖 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.

Outside diff comments:
In `@lefthook.yml`:
- Around line 73-109: Replace the unsupported deps-based ordering around
web-deps, web-prettier, and web-eslint with Lefthook group configuration using
an outer piped group and an inner parallel group. Ensure web-deps completes
successfully before web-prettier and web-eslint start, while preserving parallel
execution between the two linting jobs and their existing commands.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e400ece0-a3a5-4bd4-b1e8-955ee0228416

📥 Commits

Reviewing files that changed from the base of the PR and between 8f87e19 and 582d764.

📒 Files selected for processing (1)
  • lefthook.yml

@dcc123456
dcc123456 requested review from Lynn-Inf and yuzhichang July 16, 2026 03:38
@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 16, 2026

@Lynn-Inf Lynn-Inf 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.

LGTM

@JinHai-CN
JinHai-CN merged commit dc95e25 into infiniflow:main Jul 16, 2026
17 of 19 checks passed
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (4518a58) to head (582d764).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16969   +/-   ##
=======================================
  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.

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.

3 participants