Repository navigation
fix(core): cap exec_capture buffer to prevent OOM on unbounded linter output - #3333
Open
FlorianBruniaux wants to merge 1 commit into
Open
FlorianBruniaux wants to merge 1 commit into
FlorianBruniaux wants to merge 1 commit into
Conversation
… output pnpm lint gets hook-rewritten to `rtk lint`, which defaults to `eslint -f json .` over the whole repo. exec_capture used Command::output() with no size limit, unlike run_streaming's RAW_CAP-bounded capture. A large repo's JSON output could OOM the rtk process itself. Shared by 15 other filter modules (golangci, pip, prisma, vitest, playwright, dotnet, git...), not lint-specific. Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
|
Carried in a local fork build since 2026-08-08 (Windows 11, Heads-up for the author: as of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pnpm lintgets hook-rewritten tortk lint(see the classificationtable in
src/discover/registry.rs). Without arguments,rtk lintdefaults to eslint and scans
.(the whole repo) with-f json(
src/cmds/js/lint_cmd.rs::run). On a large repo with many violations,that JSON payload can reach hundreds of MB.
It gets captured via
core::stream::exec_capture(), which usedCommand::output()with no size limit, unlikerun_streaming(), whichalready caps captured output at
RAW_CAP(10 MiB). Result: the rtkprocess itself can OOM before any filter runs.
exec_captureis shared by 15 other filter modules (golangci, pip,prisma, vitest, playwright, dotnet, git, gt, container, ...). This wasn't
lint-specific, it was a gap in the shared capture primitive.
Fix
exec_capture/exec_capture_stdinnow read each pipe (stdout/stderr)capped at
RAW_CAP(10 MiB), still draining (and discarding) anythingpast the cap so the child process never blocks writing to a full pipe.
Behavior is unchanged below 10 MiB; above it, output is bounded instead
of crashing the process.
Testing
cargo fmt --all && cargo clippy --all-targets: cleancargo test --all: full suite green except 2 pre-existing, unrelatedfailures in
hooks::rewrite_cmd(permission-config-dependent, verifiedto fail identically on
developwithout this patch)test_exec_capture_raw_cap_at_10mb: proves the capholds and the child process exits cleanly (no pipe deadlock)
Test plan
rewrite_cmdfailures are also present ondevelopHEAD without this change