Skip to content

Remove dead code from bun_lsquic_sys, bun_trim, and bun_sema_standalone - #47355

Open
robobun wants to merge 1 commit into
mainfrom
robobun/39204bb7/dead-code-sweep
Open

robobun wants to merge 1 commit into
mainfrom
robobun/39204bb7/dead-code-sweep

Conversation

@robobun

@robobun robobun commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Behaviour change: none

Problem

  • Settings::scid_len and Settings::delay_onclose have no caller (src/lsquic_sys/lib.rs). node:quic on lsquic — Node v26 compat, HTTP/3 #32602 added them with their C shims, us_nq_settings_set_scid_len and us_nq_settings_set_delay_onclose. No commit ever called them.
  • bun_trim depends on thiserror, and bun_sema_standalone depends on bun_sema_parser. No file of either crate names the dependency.

Fix

  • Remove the two settings_setters! rows, their two extern "C" declarations, and the two NQ_SET(...) lines in packages/bun-usockets/src/node_quic_shim.c.
  • Remove the two dependency lines and the two matching Cargo.lock lines.
  • Correct because nothing names the removed items. rg 'scid_len|delay_onclose' src packages now finds one local variable and nothing else. The linker finds no reference to either shim.
  • Verified: bun bd builds and bun run rust:check-all passes on 12 targets. bun bd test ran test/js/node/quic/ (3 files) and test/js/bun/http/serve-http3.test.ts.

Background

  • bun_lsquic_sys wraps lsquic for node:quic and HTTP/3. Each settings_setters! row name => c_function : type becomes a Settings::name(v) method that calls the C shim. NQ_SET(field, type) defines that shim.
  • The linker check links the debug binary again with --gc-sections --print-gc-sections. The output lists each function that no root reaches. Both shims are on that list.
  • The sweep found nothing else outside the open pull requests. Notes has the details.

Downsides

Notes

Removed, one line each

  • Settings::scid_len and us_nq_settings_set_scid_len (table row, extern "C" declaration, NQ_SET(scid_len, unsigned)): on main, rg scid_len src packages finds these three lines and a local variable in src/runtime/node/quic/endpoint.rs. Build passes.
  • Settings::delay_onclose and us_nq_settings_set_delay_onclose (table row, extern "C" declaration, NQ_SET(delay_onclose, int)): on main, rg delay_onclose src packages finds these three lines and nothing else. Build passes.
  • thiserror in src/trim/Cargo.toml: on main, rg -w thiserror src/trim finds only the manifest line. cargo check -p bun_trim --all-targets passes.
  • bun_sema_parser in src/sema/standalone/Cargo.toml: on main, rg -w bun_sema_parser src/sema/standalone src/runtime/cli/typescript_libs.rs finds only the manifest line (the second path is the file that lib.rs includes with #[path]). cargo check -p bun_sema_standalone --all-targets passes.

cargo metadata --locked accepts the edited Cargo.lock.

Test and build runs

  • bun bd, the tests and bun run rust:check-all ran on e64b59d. After the rebase onto da867c6, cargo check --all-targets ran again for the three crates and bun_runtime.
  • test/js/node/quic/quic-stream.test.ts: 13 pass. quic-endpoint.test.ts: 9 pass and quic-sni.test.ts: 11 pass, each on the second run. The first run, directly after the build, had 2 and 1 failures.
  • test/js/bun/http/serve-http3.test.ts: 82 of 84 pass in the full run. The other two hit the 5 s timeout of the debug build. basic GET passes alone. Response(subprocess.stdout) streams over H3 passes with --timeout 60000, in 4.2 s.
  • These runs were not compared with a debug build of main.

What the sweep covered

Seen, not changed

  • ScopeBlockInfo::Begin.fallthrough (src/react_compiler/hir/visitors.rs) is written and never read. It is probably dead. It is not in this diff because the removal also edits each writer.
  • cargo check warns unused dependency on Windows and FreeBSD targets for bun_semver (in bun_analytics), bun_which (in bun_crash_handler), bun_spawn_sys (in bun_io) and bun_analytics (in bun_spawn_sys). Other targets use them, so they are not dead. A target-specific dependency table would silence the warnings.

Remove two lsquic settings setters that no code calls, with their C shims:
Settings::scid_len (us_nq_settings_set_scid_len) and
Settings::delay_onclose (us_nq_settings_set_delay_onclose).

Remove two Cargo dependencies that no file of the crate names:
thiserror in bun_trim and bun_sema_parser in bun_sema_standalone.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between da867c6 and 3b37d3a.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 4
  • packages/bun-usockets/src/node_quic_shim.c
  • src/lsquic_sys/lib.rs
  • src/sema/standalone/Cargo.toml
  • src/trim/Cargo.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@robobun

robobun commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 8:06 AM PT - Oct 29th, 2026

❌ @robobun, your commit 3b37d3a has some failures in Build #135129 (All Failures)


🧪   To try this PR locally:

bunx bun-pr 47355

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

bun-47355 --bun

@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, a small mechanical dead-code removal that is consistent on both sides of the FFI boundary.

What was reviewed:

  • Grepped the whole repo for scid_len / delay_onclose after the change: the only remaining hit is an unrelated local variable in src/runtime/node/quic/endpoint.rs, so no Rust, C, C++, or cfg-gated caller references the removed shims or Settings setters.
  • Checked src/trim/error.rs: its error enums use hand-written From impls and strum, no thiserror derive or #[from], and no file under src/trim/ (including tests/) names thiserror.
  • Checked bun_sema_standalone, including the #[path]-included src/runtime/cli/typescript_libs.rs: nothing names bun_sema_parser.
  • Cargo.lock removes exactly the two dependency edges; both bun_sema_parser and thiserror packages remain for their other dependents, with no stray churn.
Extended reasoning...

The change is a single commit of 10 deletions across five files: two unused QUIC engine-settings setters removed from the C shim (packages/bun-usockets/src/node_quic_shim.c), their matching extern "C" declarations and settings_setters! rows in src/lsquic_sys/lib.rs, and two unused crate dependencies dropped from bun_trim and bun_sema_standalone with the corresponding Cargo.lock edges. It touches the lsquic FFI surface only by deleting unreferenced symbols; no security-sensitive logic, auth, crypto, or input handling changes. Approval rests on a full-repo grep confirming no remaining reference to any removed item and that the two crates have no derive-macro or test-only use of the dropped dependencies, plus the absence of any CODEOWNERS coverage or outstanding objections on the changed paths.

@robobun

robobun commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. The diff is green on every job that ran.

CI (build 135129):

  • 184 of 188 jobs passed. That includes every build lane and the test lanes for Linux, Windows and macOS aarch64.
  • The 4 darwin x64 - test-bun jobs never started. They expired four times while they waited for an agent. That is the only reason the build is red.
  • 10 test files failed once on other lanes and passed on retry. None of them is related to this change.

How this was checked:

  • The debug binary, linked again with --gc-sections --print-gc-sections, lists us_nq_settings_set_scid_len and us_nq_settings_set_delay_onclose as unreferenced. rg finds no caller of Settings::scid_len or Settings::delay_onclose.
  • No file of bun_trim names thiserror. No file of bun_sema_standalone names bun_sema_parser.
  • bun bd builds, and bun run rust:check-all passes on 12 targets.

The pull request body has the full list of what the sweep covered.

This branch has not been deployed

No deployments
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.

2 participants