Skip to content

fix: prevent lint-staged from crashing on Windows with large file sets#3756

Merged
mrlubos merged 2 commits intomainfrom
copilot/fix-prepare-script-crash-windows
Apr 13, 2026
Merged

fix: prevent lint-staged from crashing on Windows with large file sets#3756
mrlubos merged 2 commits intomainfrom
copilot/fix-prepare-script-crash-windows

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

On Windows, lint-staged appends all matched staged-file paths as CLI arguments to each configured command. With 400+ snapshot files staged, the command line exceeded Windows's maximum length limit, causing lint-staged to batch files across ~20 separate Node.js processes and ultimately crash.

Change

Use a function instead of a plain array in lint-staged.config.js. When lint-staged receives a function, it passes the file list to the function but does not append files to the returned command strings — the commands run once on the whole directory, which is already the correct behaviour for oxfmt . and eslint . --fix.

// before
export default {
  '*': ['pnpm format', 'pnpm lint:fix'],
};

// after
export default {
  '*': () => ['pnpm format', 'pnpm lint:fix'],
};

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copilot AI linked an issue Apr 13, 2026 that may be closed by this pull request
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

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

Project Deployment Actions Updated (UTC)
hey-api-docs Ready Ready Preview, Comment Apr 13, 2026 8:41pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: 9c3f654

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 13, 2026

TL;DR — Switches the lint-staged.config.js glob entry from a plain array to a function, preventing lint-staged from appending every matched file path to the command string — which on Windows with 400+ staged files exceeded the OS command-line length limit and crashed.

Key changes

  • Use a function form in lint-staged.config.js to avoid file-path expansion — lint-staged passes matched files as CLI arguments when the config value is a plain array; using a function instead makes lint-staged run the returned commands as-is, sidestepping the Windows MAX_PATH / argument-length limit.

Summary | 1 file | 1 commit | base: maincopilot/fix-prepare-script-crash-windows

The change is a single-character diff ('*': ['pnpm format', 'pnpm lint:fix']'*': () => ['pnpm format', 'pnpm lint:fix']). When lint-staged sees a function it calls it with the file list but does not append files to the returned command strings, so pnpm format and pnpm lint:fix run once against the whole directory — which is already how oxfmt . and eslint . --fix behave.

Before: lint-staged appended every staged file path to pnpm format and pnpm lint:fix, exceeding the Windows command-line length limit with large changesets.
After: lint-staged calls the function and runs the returned commands without appending file paths, avoiding the length limit entirely.

Closes #3754.

lint-staged.config.js

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

This draft PR contains no code changes — just an empty "Initial plan" commit. Nothing to review yet. Will re-review once implementation commits are pushed.

Pullfrog  | Fix it ➔View workflow run𝕏

…ocesses on Windows

Agent-Logs-Url: https://github.com/hey-api/openapi-ts/sessions/03ec608d-b661-4244-b872-67f7043a87b6

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix prepare script crash on Windows with large file limit fix: prevent lint-staged from crashing on Windows with large file sets Apr 13, 2026
Copilot AI requested a review from mrlubos April 13, 2026 20:42
@mrlubos
Copy link
Copy Markdown
Member

mrlubos commented Apr 13, 2026

@copilot is this fix going to work cross-env? How come it wasn't an issue on other platforms before?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 13, 2026

@copilot is this fix going to work cross-env? How come it wasn't an issue on other platforms before?

Yes, the fix works cross-platform. The function form is a standard lint-staged feature supported on all OSes.

The reason it wasn't an issue on Linux/macOS before: those systems have a much higher ARG_MAX limit (typically 2 MB+), so 400+ file paths appended as CLI arguments still fit in one command and lint-staged never needed to batch them. Windows's CreateProcess API caps the command line at ~32,767 characters, which 400+ long absolute paths easily blow past — causing lint-staged to split the files across batches and spawn ~20 separate Node.js processes, eventually crashing.

Using a function instead of a plain array tells lint-staged "don't append file paths to these commands at all". oxfmt . and eslint . --fix already operate on the whole directory, so nothing is lost — on any platform.

@mrlubos mrlubos marked this pull request as ready for review April 13, 2026 21:19
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 13, 2026
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

Reviewed — no issues found.

Pullfrog  | View workflow run𝕏

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.04%. Comparing base (b31b1d7) to head (9c3f654).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3756   +/-   ##
=======================================
  Coverage   40.04%   40.04%           
=======================================
  Files         520      520           
  Lines       19243    19243           
  Branches     5726     5726           
=======================================
  Hits         7705     7705           
  Misses       9342     9342           
  Partials     2196     2196           
Flag Coverage Δ
unittests 40.04% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@mrlubos mrlubos merged commit 266efca into main Apr 13, 2026
12 checks passed
@mrlubos mrlubos deleted the copilot/fix-prepare-script-crash-windows branch April 13, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepare script crash on Windows

2 participants