Skip to content

fix: batch argv by command-line length, and leave a usable log when a run fails - #2

Merged
soroushm merged 4 commits into
mainfrom
fix/argv-length-limit
Aug 20, 2026
Merged

fix: batch argv by command-line length, and leave a usable log when a run fails#2
soroushm merged 4 commits into
mainfrom
fix/argv-length-limit

Conversation

@soroushm

@soroushm soroushm commented Aug 20, 2026

Copy link
Copy Markdown
Member

What this changes

Closes #1. File lists are split into batches by cumulative command-line length before being handed to a spawn - for both oxfmt invocations and git add - so a run over thousands of changed files no longer dies with ENAMETOOLONG on Windows. Unexpected errors now print their full stack in CI (or under --verbose), and every crash writes an oxfmt-quick-error.log report to the temp directory that can be attached to an issue as-is. Ships as 1.0.1, with release notes.

Also adds husky hooks running ai-watermark-guard on staged files and commit messages, complementing the CI checks.

Why

Every oxfmt invocation carried the whole changed-file list in a single spawn, and Windows caps a command line at 32767 characters - the 2416 CI paths in #1 hit the limit before oxfmt ran. git add was already batched, but by a fixed count of 100 paths, which deeply nested CI paths could still overrun; it now uses the same length-based split. And when the failure happened, the one-line spawnSync ... ENAMETOOLONG message was all the reporter had to go on - the stack, the error's code/syscall, and the environment now land in the CI log and the report file instead of being dropped.

Checklist

  • pnpm test:coverage passes - the package is held at 100% (66 tests; the new batch.ts and errorReport.ts are inside the enforced set)
  • pnpm lint, pnpm typecheck and pnpm format:check pass
  • Behaviour that touches git or process spawning has a test that would fail without the change - multi-batch listDifferent/format, length-based stageFiles, and the error-report content (property retention, array capping, write-failure fallback); also reproduced end-to-end on Windows with 2500 changed files
  • README updated if a flag or the API changed - no flag or API change; error output is presentation

@soroushm soroushm mentioned this pull request Aug 20, 2026
2 tasks
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@socket-security

socket-security Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedhusky@​9.1.71001006180100

View full report

A single spawn carried every changed path, and Windows caps the whole
command line at 32767 characters - 2416 CI paths met ENAMETOOLONG well
before oxfmt ran. File lists are now split by cumulative length, costed
against a 30k budget after the executable, config and flags take their
share, and each batch is spawned on its own: --list-different merges
what the batches report, format stops at the first failing batch, and
git add moves from a fixed 100 paths per call - which deep CI paths
could still overrun - to the same length-based split.

Fixes #1
An unexpected error used to surface as one line - the shape of the
ENAMETOOLONG report in #1, where the message was all there was to go on.
Now the stack prints whenever CI is set, or locally under --verbose, and
every crash also writes a report to the temp directory - version, node,
platform, command, cwd, and the inspected error with its code and
syscall kept and its arrays capped - so an issue can say attach the log
and the log is enough. The rendering lives in errorReport.ts rather
than the CLI shell, inside the enforced 100% coverage.
pre-commit fixes and re-stages what is staged; commit-msg fixes the
message itself. CI keeps the range check for what hooks never see.
@soroushm
soroushm force-pushed the fix/argv-length-limit branch from a12bb3a to f456ff2 Compare August 20, 2026 20:59
@soroushm soroushm self-assigned this Aug 20, 2026
@soroushm
soroushm merged commit cf0eed6 into main Aug 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when argv exceeds max length

2 participants