Skip to content

install: say --network-concurrency defaults to 64 in help and docs - #38759

Open
robobun wants to merge 6 commits into
mainfrom
farm/61dd026a/network-concurrency-default-64
Open

install: say --network-concurrency defaults to 64 in help and docs#38759
robobun wants to merge 6 commits into
mainfrom
farm/61dd026a/network-concurrency-default-64

Conversation

@robobun

@robobun robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

  • bun install --help (and add, remove, update, outdated, patch, publish, link, info, which share the same flag table) prints --network-concurrency <NUM> Maximum number of concurrent network requests (default 48). The eight docs/snippets/cli/*.mdx flag references and completions/bun-cli.json say 48 as well.
  • bun install actually uses 64: DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL and its proxy variant are both 64 in src/install/PackageManager.rs:289-290, and that is what init stores into MAX_SIMULTANEOUS_REQUESTS when the flag is not passed (PackageManager.rs:2276-2290).
  • The constant was raised from 48 to 64 in 2de2e9f, the same day the flag landed (Reduce default max network connection limit from 256 to 48 in bun install #14755). The help string is a separate literal (clap::param! only takes literals, see the comment above BACKEND_PARAM), so nothing tied the two together and the text was never updated.

Fix

  • src/install/PackageManager/CommandLineArguments.rs: the help string says (default 64). The param is now a named const with a const _: () = assert!(...) under it that checks both install defaults are still 64, so the next change to the constant fails to compile until the help text is updated. Verified by setting the constant to 48: the build stops with evaluation panicked: update the default in the --network-concurrency help text (and docs/snippets/cli/*.mdx) at that assert.
  • docs/snippets/cli/{install,add,remove,update,outdated,patch,publish,link}.mdx: default="64", and the four descriptions that repeated the number now say 64 too.
  • completions/bun-cli.json: the eleven copies of this flag's description updated to the text the generator would now emit. Other flags in this file are stale as well; that is left for a regeneration, as with the targeted edits in install: pnpm parity — dedupe, prune, pm licenses, audit fix, add --filter/--catalog, nested overrides, transitive update, and workspace fixes #38333.
  • Correct because the number in the help text is documentation of the constant, and the constant is 64. The assert pins the literal to the constant at compile time; the test below checks the other half, that the constant is what a plain bun install really runs with and that --help prints it.
  • Test: test/cli/install/bun-install.test.ts, "bun install --help states the --network-concurrency default that bun install actually uses". It reads (default N) out of bun install --help and hands N to expectInstallInFlightLimit, which runs a plain bun install with N+1 dependencies against a registry stub that holds every manifest request open and asserts exactly N requests end up in flight (the extra one has to wait for a slot). The stub lives in a helper so install: honor BUN_CONFIG_MAX_HTTP_REQUESTS #38744, which adds BUN_CONFIG_MAX_HTTP_REQUESTS rows to the neighbouring --network-concurrency=5 test, can use the same mechanism; the two branches currently merge without conflicts.
    • Unfixed build (help says 48): fails with Expected: 48, Received: 49, because bun puts all 49 requests in flight.
    • Fixed build: passes (25/25 across reruns of the five --network-concurrency tests under the debug build, about 1s each).
    • A real limit below the printed one, or bun exiting early, ends in the same maxInFlight assertion (checked by forcing N=65 against the 64 build: Expected: 65, Received: 64). The 30s race bound exists only for that failure path; the 500ms window is how long an over-limit request gets to show up.
    • Whole file under bun bd test: the only failures are the pre-existing bitbucket/gitlab/external-URL tests, which need internet access and fail identically on an unmodified checkout here. On CI the file passed on the x64 ASAN lane.
    • All nine commands that carry the flag print (default 64) with the debug build.
  • Also in that file (review finding): the existing --network-concurrency=<invalid> loop spawned abcdef on every iteration, so its 65537 and -1 cases tested nothing. It now passes each value and expects it echoed in the error; all three values are rejected by the current parser, so the three tests still pass.

Background

  • --network-concurrency caps how many HTTP requests bun install keeps in flight at once. The cap is a process-wide atomic in the HTTP client (MAX_SIMULTANEOUS_REQUESTS); the HTTP thread starts queued requests until that many are active and parks the rest (src/http/HTTPThread.rs around line 890), which is why a registry stub that never answers observes exactly the cap.
  • The flag is defined once in SHARED_TAIL_PARAMS and concatenated into every package-manager command's flag table, so one help string covers all of the commands listed above.
  • const _: () = assert!(...) is a compile-time assertion: the expression is evaluated while compiling and a false result is a build error. The crate already uses it to pin literals to the constants they mirror (for example src/install/npm.rs pins the manifest cache header length).
  • docs/snippets/cli/*.mdx are the flag-reference blocks included by the docs/pm/cli/*.mdx pages; completions/bun-cli.json is a checked-in dump of the --help output that misctools/generate-cli-completions.ts produces.

no test proof · iteration 0 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/cli/install/bun-install.test.ts

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4599bf84-fbfb-4637-80e4-3da1385ecb51

📥 Commits

Reviewing files that changed from the base of the PR and between c2fa121 and 0c276fc.

📒 Files selected for processing (11)
  • completions/bun-cli.json
  • docs/snippets/cli/add.mdx
  • docs/snippets/cli/install.mdx
  • docs/snippets/cli/link.mdx
  • docs/snippets/cli/outdated.mdx
  • docs/snippets/cli/patch.mdx
  • docs/snippets/cli/publish.mdx
  • docs/snippets/cli/remove.mdx
  • docs/snippets/cli/update.mdx
  • src/install/PackageManager/CommandLineArguments.rs
  • test/cli/install/bun-install.test.ts

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

@robobun

robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 3:59 AM PT - Aug 15th, 2026

@robobun, your commit 0c276fc75e9c26052131d5aa079a553bef30c9b6 passed in Build #97411! 🎉


🧪   To try this PR locally:

bunx bun-pr 38759

That installs a local version of the PR into your bun-38759 executable, so you can run:

bun-38759 --bun

@robobun

robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

Status: ready for review.

Reproduced on an unmodified checkout: bun install --help prints (default 48) for --network-concurrency, while a plain bun install against a registry stub that holds manifest requests open reaches 64 requests in flight (DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL in src/install/PackageManager.rs is 64). The new test in test/cli/install/bun-install.test.ts fails on that build with Expected: 48, Received: 49 and passes with the help string fixed.

Current shape after review: the help string is fixed and pinned to the constant with a compile-time assert (changing the constant again fails the build until the text is updated), the docs snippets and completions/bun-cli.json say 64, the test's registry stub is a helper that #38744 can reuse for its env-var rows (the two branches merge cleanly), and the adjacent invalid-value loop now really passes 65537 and -1 (0c276fc, review finding). No functional change.

CI for 0c276fc (build 97411): 177 of 179 jobs passed, no failing tests; the only annotations are retry-passing flakes on unrelated files, and the remaining two jobs are darwin 14 aarch64 test shards that have been waiting for an agent for several hours. The install test file itself passed on every lane that ran it, including x64 ASAN. Nothing left to do on this side; this is ready to merge once those shards report.

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

LGTM — straightforward help-text and docs correction (48 → 64) matching the actual constant, with a regression test that ties the printed default to observed concurrency. The inline nit about bounding the first await is worth taking but doesn't block.

Extended reasoning...

Overview

The only src/ change is a one-word help-string edit in CommandLineArguments.rs ((default 48)(default 64)). The rest is eight docs/snippets/cli/*.mdx files and eleven copies in completions/bun-cli.json receiving the identical mechanical 48→64 replacement, plus a new test in bun-install.test.ts that parses the default out of --help and verifies against a registry stub that a plain bun install puts exactly that many requests in flight.

I confirmed DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL = 64 at src/install/PackageManager.rs:289 and that no default 48 strings remain anywhere in the tree.

Security risks

None. Pure documentation/help-text; no runtime behavior changes. The test uses a local Bun.serve stub via the existing withContext/setContextHandler harness — no external network.

Level of scrutiny

Low. The help string is documentation of a constant; the constant is verifiably 64. The docs and completions edits are mechanical mirrors of the same fact. The new test is additive and follows file conventions (describe.concurrent, withContext, bunEnv spread with BUN_CONFIG_MAX_HTTP_REQUESTS: undefined, pipes drained via Promise.all, await using for cleanup).

Other factors

One nit was filed inline: if the real limit ever drops below the help-text value, the first await documentedLimitReached.promise deadlocks until the file's 5-minute default timeout instead of failing fast on expect(maxInFlight).toBe(documented). That's a diagnostics-quality concern for a hypothetical future regression, not a correctness or flakiness issue for the code as landed (help and constant are both 64). Worth addressing but not merge-blocking.

Comment thread test/cli/install/bun-install.test.ts Outdated

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

LGTM — the follow-up commit bounds the documentedLimitReached wait with proc.exited and a 30s sleep, so the actual-lower-than-documented case now fails with the maxInFlight diagnostic instead of the 5-minute file timeout. That was the only outstanding concern.

What was reviewed:

  • Confirmed DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL (and the proxy variant) are both 64 in src/install/PackageManager.rs, so the help string, eight docs snippets, and eleven completion entries are all consistent with the real default.
  • Grepped for remaining default 48 / "48" references — none related to this flag.
  • The new test uses the existing withContext registry stub, drains stdout/stderr/exited concurrently, unsets BUN_CONFIG_MAX_HTTP_REQUESTS, and both bounded waits carry a comment naming why no direct signal exists.
Extended reasoning...

Overview

This PR corrects the documented default for --network-concurrency from 48 to 64 across one help-string literal in src/install/PackageManager/CommandLineArguments.rs, eight docs/snippets/cli/*.mdx flag references, and eleven entries in completions/bun-cli.json. It adds a test to test/cli/install/bun-install.test.ts that parses the number out of bun install --help and verifies against a local registry stub that a plain bun install reaches exactly that many concurrent requests and no more.

Prior review addressed

My earlier inline comment flagged that await documentedLimitReached.promise was unbounded, so an actual-limit-lower-than-documented mismatch would deadlock until the file's 5-minute default timeout with no diagnostic. Commit b7a77ff changes this to Promise.race([documentedLimitReached.promise, proc.exited, Bun.sleep(30_000)]) with an explanatory comment. In the passing case the promise resolves in ~1s so the 30s is never spent; in the failing case the assertion expect(maxInFlight).toBe(documented) runs after ~30s and reports the actual value. That fully addresses the concern.

Security risks

None. The only src/ change is a static help-string literal; everything else is docs, completions JSON, and a test. No auth, crypto, permissions, or user-input handling is touched.

Level of scrutiny

Low. This is a mechanical documentation correction where the true constant (64) is verified by reading PackageManager.rs:289-290 and by the new test which observes the runtime limit end-to-end. There is zero behavioral change to the package manager. The test is added alongside the existing --network-concurrency=<invalid> tests and follows the file's withContext(defaultOpts, ...) pattern.

Other factors

  • Ruled out stragglers: grepped the repo for default 48 and "48" — the only hits are unrelated fixtures/docs, so nothing was missed.
  • The test's two bounded sleeps (30s for the reached-limit wait, 500ms for the not-exceeded window) each carry a comment naming why no observable signal exists, satisfying the REVIEW.md rule for literal sleeps ≥ 50ms. In the green path neither is fully waited on — documentedLimitReached resolves as soon as 64 requests arrive, and the 500ms window is the negative-observation bound.
  • BUN_CONFIG_MAX_HTTP_REQUESTS is explicitly cleared from the child env so the harness's ambient env cannot skew the observed default.
  • No CODEOWNERS-sensitive paths, no design decisions, no API surface changes.

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

LGTM — the earlier feedback on bounding the first await is addressed in b7a77ff.

What was reviewed:

  • Confirmed DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL is 64 in src/install/PackageManager.rs:289-290; the one src/ change is the help string literal.
  • All eight docs snippets and eleven completions/bun-cli.json entries updated; grepped docs/ for remaining default 48 — none.
  • Test now races the reached-limit wait against proc.exited and a 30s bound, resolves on >=, drains pipes concurrently, and asserts maxInFlight === documented so both mismatch directions fail with a diagnostic.
  • The one CI failure (test/regression/issue/09041.test.ts ASAN) is unrelated — this PR touches no executed native code.
Extended reasoning...

Overview

The PR corrects a stale documented default: --network-concurrency help text and docs said 48, but DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL in src/install/PackageManager.rs:289 is 64 (raised in 2de2e9f). The change is one help-string literal in CommandLineArguments.rs, eight docs/snippets/cli/*.mdx snippets, eleven descriptions in completions/bun-cli.json, and a new test in bun-install.test.ts that ties the printed default to the observed in-flight request cap.

Security risks

None. No executed code paths change — the sole src/ hunk is a display string in a clap::param! help literal. Docs and completions JSON are non-executable.

Level of scrutiny

Low for the fix itself (mechanical 48→64 across documentation surfaces, verified against the source constant). Medium for the new test, which was already reviewed once: the previous run flagged an unbounded await that would hang instead of failing diagnostically when actual < documented; the author addressed it in b7a77ff with Promise.race([documentedLimitReached.promise, proc.exited, Bun.sleep(30_000)]) and a >= resolver, and verified both failure directions produce the intended assertion message. The test follows harness conventions (withContext, setContextHandler, bunExe/env, await using, concurrent pipe drain, {...env, KEY: undefined} to clear BUN_CONFIG_MAX_HTTP_REQUESTS).

Other factors

  • Grepped docs/ for any remaining default 48 / "48" on this flag — none left.
  • The 500ms Bun.sleep is a bounded observation window for a negative condition ("no request beyond the limit shows up"), which REVIEW.md permits; the passing path resolves via the promise long before then.
  • The single CI failure is an ASAN error in test/regression/issue/09041.test.ts, which this PR does not touch and cannot affect (no native code change).
  • The prior inline review thread is marked resolved.

Comment thread src/install/PackageManager/CommandLineArguments.rs Outdated
Comment thread test/cli/install/bun-install.test.ts

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

LGTM — mechanical 48→64 sync across help text, docs snippets, and completions, pinned to the source constant with a compile-time assert.

What was reviewed:

  • Confirmed DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL and the proxy variant are both 64 in src/install/PackageManager.rs:289-290, and that private consts are visible to the child module via super::.
  • Grepped for remaining 48 references tied to network-concurrency across the repo — none.
  • The earlier unbounded-await issue is resolved: limitReached now races proc.exited and a 30s bound, and resolves on >= so the over-limit case unblocks it too.
  • The remaining inline note about the adjacent "abcdef" loop is pre-existing and non-blocking.
Extended reasoning...

Overview

This PR corrects the documented default for --network-concurrency from 48 to 64 across three surfaces: the CLI help string in src/install/PackageManager/CommandLineArguments.rs, eight docs/snippets/cli/*.mdx flag-reference blocks, and eleven copies in completions/bun-cli.json. The actual runtime constant (DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL in PackageManager.rs:289) has been 64 since it was raised in 2de2e9f; only the disconnected string literals were stale. The Rust change extracts the param to a named const (matching the existing BACKEND_PARAM pattern immediately above) and adds a const _: () = assert!(...) that pins the literal to both install-default constants at compile time. A new test in bun-install.test.ts parses (default N) from bun install --help and verifies a plain bun install against a request-holding registry stub reaches exactly N in-flight requests.

Security risks

None. This is a documentation string change plus a compile-time assertion and a test. No runtime behavior, parsing, validation, or network-facing code path changes. The test uses a local Bun.serve stub via the existing withContext/setContextHandler harness — no external network contact.

Level of scrutiny

Low. The docs and completions edits are pure string substitutions verified by grep (no remaining 48 references for this flag anywhere in the tree). The Rust change is nine lines that follow the neighboring BACKEND_PARAM idiom exactly and introduce no runtime code — only a const item and a const-eval assertion. I confirmed the private consts in the parent module are visible to the child module via super:: (Rust private items are accessible from descendant modules), and the assertion compares usize == 64 which const-evaluates cleanly. The test is the most substantive piece; it was iterated once in review to bound the wait so the actual-below-documented failure mode surfaces as an assertion instead of a file-timeout hang, and the author verified both failure directions (Expected: 48, Received: 49 on the unfixed help; Expected: 65, Received: 64 when forcing the over-documented case).

Other factors

All prior review feedback is resolved: the unbounded await documentedLimitReached was replaced with a Promise.race against proc.exited and a 30s bound in b7a77ff, and the paragraph-length justification comment above NETWORK_CONCURRENCY_PARAM was removed in 5d9af37 per the comment-cop check (the assert message carries the same information). The one inline note I left on this revision — the hardcoded "abcdef" in the adjacent invalid-value loop — is explicitly pre-existing, unchanged by this PR, and marked non-blocking. The test clears BUN_CONFIG_MAX_HTTP_REQUESTS from the environment to avoid leakage, drains stdout/stderr/exited concurrently, and the expectInstallInFlightLimit helper is factored out for reuse by #38744 (which the description says merges cleanly). CI passed the install test file on the x64 ASAN lane; the only file failures reported are pre-existing internet-dependent tests unrelated to this diff.

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

LGTM — the earlier review feedback (bounded wait on limitReached, and the "abcdef"input fix in the invalid-value loop) is in, and the comment-cop note is addressed.

What was reviewed:

  • The help literal now matches DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL{,_FOR_PROXIES} = 64 in PackageManager.rs, and the const _: () = assert!(...) pins it — child modules can see parent-private consts, so super::… resolves.
  • expectInstallInFlightLimit: ctx.requested is bumped by the shared server before the custom handler runs, so the limit + 1 assertion holds after release.resolve() lets the last request through; BUN_CONFIG_MAX_HTTP_REQUESTS is masked out of the env.
  • Docs/completions edits are the mechanical 48→64 across all eight snippets and eleven completion entries; no other flag descriptions were touched.
Extended reasoning...

Overview

This PR corrects the --network-concurrency default shown in bun install --help (and the eight sibling package-manager commands that share SHARED_TAIL_PARAMS) from 48 to 64, matching the actual constant DEFAULT_MAX_SIMULTANEOUS_REQUESTS_FOR_BUN_INSTALL = 64 in src/install/PackageManager.rs:289-290. It updates the eight docs/snippets/cli/*.mdx flag references and the eleven copies in completions/bun-cli.json, extracts the param to a named const NETWORK_CONCURRENCY_PARAM (mirroring the existing BACKEND_PARAM pattern), and adds a compile-time const _: () = assert!(...) so a future change to either constant fails the build until the help text is updated. A new test in bun-install.test.ts reads the default from --help and verifies a plain bun install against a stalling registry stub reaches exactly that many in-flight requests. It also carries a one-token drive-by fix to the adjacent invalid-value loop (previously all three iterations passed "abcdef").

Security risks

None. This is a help-text/documentation correction with no runtime behavior change; the constant itself is untouched. The test spawns bun against a local in-process Bun.serve registry via the existing dummy.registry harness — no external network.

Level of scrutiny

Low-to-moderate. The docs and completions edits are mechanical string replacements. The Rust change is nine lines: a hoisted const param plus a compile-time assert, following the file's existing BACKEND_PARAM idiom, and a one-line replacement in the SHARED_TAIL_PARAMS array. I verified the referenced constants exist in the parent module and are 64, and that Rust visibility rules allow super:: access from a child module to a parent's private consts. The test additions are the only part warranting real scrutiny, and they went through two rounds of feedback already.

Other factors

All three prior review comments have been addressed in follow-up commits: (1) the unbounded await limitReached.promise is now raced with proc.exited and a 30s bound so a real limit below the documented one fails on the maxInFlight assertion instead of the file timeout (b7a77ff); (2) the paragraph-long comment above NETWORK_CONCURRENCY_PARAM was removed since the assert message says the same thing (5d9af37); (3) the pre-existing hardcoded "abcdef" in the invalid-value loop now uses input and the assertion includes : ${input} (0c276fc). The author verified both failure directions of the new test manually and confirmed the file passes on the ASAN CI lane. The helper is structured for reuse by #38744 and the author confirmed the branches merge cleanly. Imports (setContextHandler, TestContext, spawn, env) are all already present in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant