Repository navigation
Conversation
|
Updated 8:15 AM PT - Oct 17th, 2026
✅ @robobun, your commit cb5d1aa1f346e809be1fcdaeea5f786cc9e812f3 passed in 🧪 To try this PR locally: bunx bun-pr 45709That installs a local version of the PR into your bun-45709 --bun |
|
Status: ready for review. The diff is green. How each deletion was verified:
CI on cb5d1aa: 179 of 181 jobs passed. The other two are macOS x64 test jobs that wait for an agent. Five test files failed once and passed on a retry or alone: The pull request body lists every removed item. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe pull request narrows build configuration options, changes nested CMake path and platform flag handling, and updates code generation behavior. It also removes selected Rust re-exports, HTTP/2 window defaults, and commented-out code. ChangesBuild configuration
Code generation
Rust public exports
HTTP/2 window initialization
Commented code cleanup
Suggested reviewers: Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
… crate roots - generate-classes: the `builtin:` property kind, the class-level `enumerable` option, and the `detach()` member emitted into every generated class. No .classes.ts file uses the options and nothing calls detach(). - generate-host-exports: the `reaction` shape. No HOST_EXPORT marker has that signature. - builtins: `$isPromiseFulfilled`, `$isPromiseRejected`, `$alwaysInline` and the `WEBCORE_BUILTIN_*` defines. No builtin uses them. - cppbind: `PositionedError.notes`, which nothing fills. - scripts/build: NestedCmakeBuild.extraCFlags, extraCxxFlags, libSubdir, sourceSubdir and pic, CompileOpts.pool, NinjaOptions.ninjaVersion and the function form of Dependency.patches. Nothing sets them. - .buildkite/ci.ts: three unused `options` parameters. - Crate-root re-exports that no code names, in bun_core, bun_jsc, bun_css, bun_collections, bun_sys, bun_js_parser_jsc, bun_resolver, bun_bundler, bun_install and bun_spawn. - Commented-out code last touched between 2022 and 2025, and one unreachable statement in NodeSqlite.cpp.
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs; because it removes public surface across ten Rust crate roots plus codegen and build-script options in one 42-file sweep, a human look is still worthwhile — mainly to confirm the non-Linux cargo checks the description cites ran on the final base.
What was reviewed:
- Every removed crate-root re-export (bun_core, bun_jsc, bun_css, bun_resolver, bun_bundler, bun_collections, bun_sys, bun_js_parser_jsc, bun_install, bun_spawn): grepped for path-qualified, grouped-
use,$crate::, and glob-import (crate::jsc::*in bun_runtime) spellings including cfg-gated code — no users outside the defining modules;#[bun_jsc::host_fn]expands through__macro_support, not the removed root names. - Codegen: no
.classes.tssetsbuiltin:or class-levelenumerable; the onlydetach()callers are on the hand-writtenJSNodeHTTPServerSocket, which declares its own; noHOST_EXPORTfn has the(ThisPtr, JSGlobalObject, CallFrame)signature the removedreactionshape matched;$alwaysInlineis still parsed generically but now silently ignored (only the.d.tsguards against new uses). - bun_spawn
From<bun_sys::Error> for Error: no?site in src/spawn relies on it (thestd::io::ErrorandError::Sys(SystemErrno)paths are unaffected), but note this impl is present in 11 other crates'error.rsas part of the shared error-enum template, so dropping it only here is a convention divergence a maintainer may want to weigh. - h2
Defaultimpls: allSendWindow/RecvWindowconstruction goes throughnew(); no containing struct derivesDefault.
Extended reasoning...
The change deletes unused re-exports from ten Rust crate roots, unused generator features in src/codegen (builtin property kind, class-level enumerable, generated detach(), reaction host-export shape, two promise-status macros, $alwaysInline, WEBCORE_BUILTIN defines), unused NestedCmakeBuild/CompileOpts/NinjaOptions fields in scripts/build, two unused trait impls, and assorted commented-out lines in C/C++/JS; it touches no security-sensitive surface. My greps found no remaining user of any removed name, including cfg-gated and macro-expanded paths, and the bug hunt ran dry. I deferred rather than approved because the sweep spans 42 files and its correctness on macOS/Windows/FreeBSD rests on the author's cross-target cargo checks, which cannot be reproduced in this environment, and because removing the From<bun_sys::Error> impl from bun_spawn alone diverges from the error-enum pattern the other crates keep.
bun_runtime: Default for the HTTP/2 SendWindow and RecvWindow. Callers use new(). Keep the two perf command lines in scripts/trace.sh.
d4bf10b to
cb5d1aa
Compare
|
Two changes since the review above:
The rebase onto 017b243 also dropped the three sqlite deletions, because #45304 rewrote those lines. The diff is now 39 files, 271 lines removed, 81 added. |
|
This PR and #41344 merge without a git conflict, and the result does not compile.
If both land as they are, main does not compile. Two ways out:
|
…ent.cpp (#45764) ### Problem - 29 lines in 6 files have no user. - `source_file`, `compare_types` and `symbol_to_string` in the `queries!` list of `src/lint/types/mod.rs` have no caller. The list generates the only call of the `Services` functions of the same names in `bun_sema`. The trait is `pub`, so rustc does not check it. - `BunProcess.cpp` declares five `using X = JSC::X;` aliases that it never names. `DirEntType` in `NodeDirent.cpp` has three enumerators that nothing names. ### Fix - Delete the three list lines with their `Services` functions (21 lines), the five aliases and the three enumerators. - Correct because a word search over the sources, the tests and the generated code finds no user, and the workspace compiles for 12 targets. - Verified: `bun bd`, `bun run rust:check-all`, `cargo check --workspace --all-targets`, 8 test files (Notes). - Self-reviewed: 41 concerns raised, 33 addressed. Rejected: a `pub(crate)` narrowing of `Queries` (`resolve_name` needs a caller first), and a hold until earlier sweeps merge. ### Background - `queries!` lists each question that a lint handle (`Type`, `TsSymbol`) can ask the type checker. One line generates a `Queries` method and a forwarding call to `Services` in `bun_sema`. - `BunProcess.cpp` compiles as its own unit with `using namespace JSC;`, so the aliases change no name lookup. - A deletion of unreferenced code has one possible place, so no other design was weighed. ### Downsides - A later lint handle that needs one of the three queries must restore it. - None found for users. Checked: the heads of all 5,559 open pull requests, 12 targets, the tests in Notes. Behaviour change: none <details><summary>Notes</summary> **Removed** - `src/lint/types/mod.rs`: the `queries!` lines `source_file`, `compare_types` and `symbol_to_string`. No call of these names has a `Queries` receiver. The calls that exist go to other functions: `Checker::compare_types` and `Checker::symbol_to_string` in `bun_sema`, a private `compare_types` in `prefer_optional_chain.rs`, and the parser's `source_file`. With `Queries` made crate-private in a scratch edit, rustc reports `resolve_name` as the only query left that is never used. - `src/sema/check/services.rs`, `services/types.rs`, `services/symbols.rs`: `Services::source_file`, `Services::compare_types`, `Services::symbol_to_string`. The generated forwarding call was the only user. What they call (`Files::by_path`, `Checker::compare_types`, `Checker::symbol_to_string`, `Checker::prop_to_string`) keeps other callers. - `src/jsc/bindings/BunProcess.cpp`: the aliases `Exception`, `JSModuleLoader`, `JSModuleRecord`, `SourceOrigin`, `JSNonFinalObject`. None of the names appears in the rest of the file. The same block in `Path.cpp` and `ZigGlobalObject.cpp` is left to #43378 and #42431. - `src/jsc/bindings/NodeDirent.cpp`: the enumerators `Whiteout`, `Door` and `EventPort` of `DirEntType`, all equal to `Unknown`. No C or C++ file names them. **Open pull requests** - Compared at 2026-10-17 16:40 UTC on main 017b243 with the heads of all 5,559 open pull requests, drafts and every author included. - 156 of them touch a file of this diff (151 touch `BunProcess.cpp`). A trial merge of each with main and with this branch (`git merge-tree`) shows that the branch adds a conflict to none. - None deletes one of these lines. None adds a use of a removed name: the added lines were searched for the three query names, the five alias names in `BunProcess.cpp`, and the three enumerators. **Found dead in this run, and left alone** - Already gone on main: three lines in `JSSQLStatement.cpp` and `NodeSqlite.cpp` (#45304). - Another open pull request deletes or rewrites them: 13 commented-out lines in uSockets, uWS, `JSEventTargetCustom.cpp` and `src/node-fallbacks/url.js` (#45709, and #43730 for `url.js`), two typedefs in `InspectorHTTPServerAgent.cpp` (#45725), the `BUN_WEBKIT_VERSION` fallback in `BunProcess.cpp` (#41729), a commented-out line in `src/js/internal/html.ts` (#45682). - An open pull request uses them: `Event::currentTargetIsInShadowTree()` and the `MediaTime` overload of `JSConverter<IDLUnrestrictedDouble>` (#45415). - Held by an earlier sweep for a reason that still holds: the QUIC setters `scid_len` and `delay_onclose` (#43976, and #40220 changes the line above them). - `resolve_name`, the fourth query with no caller. tsgolint's `prefer-readonly` calls `ResolveName` and Bun's port does not, which gives a wrong autofix for a global enum. The fix is handed off and needs the query. After it, `Queries` can become `pub(crate)`, and rustc then guards the list. - Mirrors of typescript-eslint and tsgolint: the write-only fields `ThenCall::on_fulfilled`, `FinallyCall::on_finally`, `BaseTypeOfClassMember::base_type` and `heritage_token`, `TargetElement::is_shorthand`, with `TsNode::token` (as #45402 held them). Also 33 functions from macro lists in `src/lint/types/` that nothing calls, and `File::expr_tags_in_tree`. - Debugging aids: 25 hand-written `Debug` impls in `bun_lint`, 5 in `bun_format`, and `Display` for `Difference`, `FilePoll` and `Part`. - Handed off: the plugin `target` value that nothing reads (`BundlerPlugin::target`, three more members, a parameter of `JSBundlerPlugin__create`, and the Rust enum). Its removal changes an FFI signature. - Needs a decision: `PerformanceResourceTiming` cannot be constructed, so `ResourceTiming.cpp`, `NetworkLoadMetrics.cpp` and `ServerTiming.h` are reachable only from its getters. **How the candidates were found** - Ten text searches, one for each area: `src/js`, the C++ bindings (three parts), uSockets and uWS, the build scripts, the side packages, the three new crates, and commented-out code. - A relink of the debug build with `-Wl,--gc-sections`, with each dropped function mapped to its source line by `llvm-nm -l`: 517 C++ functions and 607 Rust function lines. Almost all are Windows or macOS code, release-only code, or are deleted by an open pull request. - For `bun_sema`: `pub` narrowed to `pub(crate)` on each item that no other crate names, in a scratch tree. rustc reported nothing new. - For 39 trait impls that the linker drops: delete all, compile for linux, windows and darwin and with `--all-targets`, put back each impl that an error names. What stayed deleted is a debugging aid. **Tests, debug build of this branch** (with `--timeout 600000`, because the lint and check tests need more than the default with a debug build) - `test/cli/lint/conformance.test.ts`: 3 pass. - `test/cli/lint/rules.test.ts`: 16 pass. - `test/cli/lint/native-rules.test.ts`: 166 pass. - `test/cli/lint/bun-rules.test.ts`: 100 pass. - `test/cli/check/check.test.ts`: 599 pass, 42 skip. - `test/js/node/process/process.test.js`: 188 pass, 5 skip. - `test/js/node/fs/dir.test.ts`: 23 pass. - `test/regression/issue/24129.test.ts`: 2 pass. </details> <!-- robobun:evidence:begin --> --- **no test proof** · iteration 0 · the description declares no behaviour change, so there is no failing test to prove; the existing suite in CI is the check <!-- robobun:evidence:end -->
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-17. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Problem
src/codegen/generate-classes.tsemitsvoid detach() { m_ctx = nullptr; }into 93 generated classes. Nothing calls it.Fix
bun bd,bun run rust:check-all(12 targets),cargo check --workspace --all-targets,cargo check --workspace --release. The generated code changes only where intended.build.ninjaand.buildkite/ci.jsonare byte-identical. Tests: see Notes.Background
generate-classes.tsturns*.classes.tsfiles into C++ wrapper classes.generate-host-exports.tsturns// HOST_EXPORT(...)markers intoextern "C"thunks.replacements.tsandbundle-functions.tscompile the JavaScript insrc/js/builtins.pub use module::Nameline inlib.rs. It lets other crates writebun_core::Name. The items stay. Only the unused short names go.NestedCmakeBuilddescribes a dependency that its own CMake project builds. Only a local WebKit build uses it.Downsides
src/,packages/,scripts/,test/,bench/,docs/or the generated code, and no line of this diff is in the 61 open dead-code pull requests.Behaviour change: none
Notes
Removed, by group
Code generators (
src/codegen):generate-classes.ts,class-definitions.ts: thebuiltin:property kind. Its last user,Glob.classes.ts, went away in One bindgen: replace bindgen v1 and v2, add classes, generate the Rust side #45104.generate-classes.ts,class-definitions.ts: the class-levelenumerableoption. No.classes.tsfile sets it. The property-levelenumerable(sockets) stays.generate-classes.ts: thedetach()member of every generated class (93 copies inZigGeneratedClasses.h). Nothing calls it.generate-host-exports.ts: thereactionshape. NoHOST_EXPORTmarker has that signature since the cron reactions became plain host functions.replacements.ts,builtins.d.ts: the$isPromiseFulfilledand$isPromiseRejectedmacros. No builtin uses them.$isPromisePendingexpands to the same text as before.bundle-functions.ts,builtins.d.ts: the$alwaysInlinedirective, and the#define WEBCORE_BUILTIN_<FILE>_<FN> 1line (49 defines that nothing tests).cppbind.ts:PositionedError.notes. Nothing fills it, so the loop that prints notes never runs.generate-jssink.ts: a second#include "BunClientData.h"in the same emitted file.Build scripts:
scripts/build/source.ts:NestedCmakeBuild.extraCFlags,extraCxxFlags,libSubdir,sourceSubdirandpic, with their readers. The onlynested-cmakedependency (WebKit) sets none of them.DirectBuild.picstays.scripts/build/source.ts: the function form ofDependency.patches. All 14 dependencies pass an array.scripts/build/compile.ts:CompileOpts.pool.scripts/build/ninja.ts:NinjaOptions.ninjaVersion. No caller passes them.scripts/build/deps/lsqpack.ts: an unusedcfgparameter..buildkite/ci.ts: the unusedoptionsparameter ofgetTraceOrderStep,getTestBunStepandgetWindowsSignStep.Rust, crate-root re-exports that no code names (81 names):
bun_core: 44 of the 63 names flattened fromstring::immutable(every user writesstrings::X),BoundedArrayAligned,is_slice_in_buffer_t,WTFStringImplPtr.bun_jsc:CoerceTo,ForEachCallback,ExceptionValidationScopeGuard,TopExceptionScopeGuard,call_check_slow_at,call_false_is_throw_at,call_null_is_throw_at,call_zero_is_throw_at,host_construct_result,HostFnEntry,AbortHandleOwner,ExternColumnIdentifierValue,ConcurrentCppTask.bun_css:ToCssResult,PseudoClasses,LABColor,PredefinedColor,BasicParseError,MinifyErrorKind, and thecss_printeralias.bun_resolver:DirEntryResolveQueueItem,FlushMode,MatchStatus,ResultFlags.bun_bundler:cross_chunk_import,JSMeta,DefineExt.bun_collections:HiveBox.bun_sys:stat_birthtime,stat_ctime.bun_js_parser_jsc:data_to_js,string_to_js.bun_install:AuthType.bun_spawn:sync::spawn_with_argv.Rust, trait impls that nothing calls:
src/runtime/api/bun/h2/flow_control.rs:Default for SendWindow,Default for RecvWindow. Callers usenew().Commented-out code, last touched between 2022-03 and 2025-09:
packages/bun-usockets: a disabledassertinbsd.c, a disabled stub inepoll_kqueue.c, two supersededus_create_udp_socketprototypes inlibusockets.h.packages/bun-uws/src/ChunkedEncoding.h: a debugprintf.src/jsc/bindings/webcore/JSEventTargetCustom.cpp:// #include "DOMWindow.h".src/js/builtins/ConsoleObject.ts,src/css/build-prefixes.js,src/node-fallbacks/url.js(four export entries for names the file no longer has),src/runtime/bake/bun-framework-react/server.tsx.Method
--gc-sections --print-gc-sectionslists 272 hand-written functions that the linker drops. The open pull requests already remove about 210 of them. Every other one has a caller on Windows or macOS, so none is in this diff.-fsyntax-onlypass over 606 files with-Wunused-function -Wunused-macros -Wunused-member-function -Wunused-template -Wunreachable-code. The build passes-Wno-unused-function. It finds eight unused static functions and macros. Open pull requests remove all of them.Display for FilePollhas a user only in the kqueue path (macOS, FreeBSD), andDefault for Bytesonly on Windows.tsc --noUnusedLocalson the five lint projects finds no unused local.src/,packages/,scripts/,test/,bench/,docs/and the generated code.Verification
All of these ran with the branch on 017b243, unless a line says otherwise:
bun bd(debug, ASAN).bun run rust:check-all: 12 of 12 targets. An earlier run failed on macOS, FreeBSD and Windows for two trait impls. They are not in this diff.cargo check --workspace --all-targets.cargo check --workspace --release, with the code of a release configure. This one ran on 0ffddcd, four commits of main earlier.build/debug/codegendiffers from the same directory before the change in three files only.ZigGeneratedClasses.hloses the 93detach()blocks,WebCoreJSBuiltins.hloses the 49WEBCORE_BUILTIN_*defines,JSSink.cpploses the second include. The generated Rust, the.d.tsfiles and the module registry are byte-identical.generate-host-exports.tswrites the same file with and without thereactionshape.build.ninjaand the other 405 generated files are byte-identical before and after in five configurations (debug,release,debug-local,release-local,debug --archive-deps=on). The two local ones reach the nested CMake code..buildkite/ci.jsonis byte-identical for a pull request build, a main build and a release build.tsc --noEmitforscripts/buildandsrc.prettier --check,clang-format --dry-runandcargo fmt --checkon the files of the diff.test/internal/source-lints/: 182 pass with the release binary.test/internal/build-*.test.ts,macos-cross-config.test.ts,rust-check-all.test.ts): 102 pass with the release binary. With the debug binary, six tests ofbuild-cli-config-flags.test.tsreach the 5 s default timeout.test/internal/bindgen.test.ts(112),test/js/web/fetch/fetch-http2-client.test.ts(88),test/js/bun/udp/udp_socket.test.ts,test/bake/dev/bundle.test.ts(29),test/js/bun/spawn/spawn-maxbuf.test.ts(16).test/js/bun/sqlite/sqlite.test.js: one failure,#13082, which does 198 full collections and takes 9 s to 13 s on the debug build against the 5 s default. It times out the same way with a binary linked from the objects of main.test/js/bun/console/console-table.test.ts: one GC test (cell values survive a full GC) takes between 3.5 s and 6.5 s on the debug build, against the 5 s default. It takes 4.4 s with a binary linked from the objects of main. All other tests pass.Follow-up candidates, not in this diff
These need a maintainer decision, or are not certain:
src/js/internal/assert/myers_diff.ts: themyersDiffexport and the Rustmyers_diffhost function behind it (src/runtime/node/node_assert_binding.rs,Output::Listinnode_assert.rs). No JavaScript reads them. Node's own internal module has the export.src/js/internal/async_context_frame.ts:AsyncContextFrame.exchange.src/js/internal/quic/quic.ts: thegetQuicStreamStateandgetQuicSessionStateexports. No reader, but they mirror Node's internal surface for tests that run with exposed internals.src/codegen/generate-host-exports.ts: therustABI ofHOST_EXPORT(about 31 lines). No marker uses it.test/internal/source-lints/host-export-callers.test.tsmirrors the grammar and must change with it.src/codegen/cppbind.ts: thefalse_is_throwmode ofZIG_EXPORT. No C++ function has the tag. Three Rust doc comments name it.src/codegen/internal-module-registry-scanner.ts: thestartsWith("bun:")arm never matches, because the module list holds paths such asbun/ffi.ts. It can be a typo for"bun/"and not dead code.configurable: falsein 26.classes.tsfiles is the default of the generator. To remove the option and the 60 lines that set it does not change the generated code.src/sys/lib.rs: 38 macOS names inpub mod c'spub use libc::{...}and 11 Windows type re-exports insrc/sys/windows/mod.rshave noc::or root user.src/bun_core/util.rs: the read-onlyaccessor @ fieldarm ofextern_union_accessors!has no invocation.src/css/values/color.rs: the@gamut nonearm ofdefine_colorspace!.src/event_loop/AnyEventLoop.rs:Clone for JsPosterhas no caller. Thecloneslot of its vtable must go with it.src/spawn/error.rs:From<bun_sys::Error> for Errorhas no user on any target. Eleven other crates keep the same impl in their error enum, so this diff leaves it.packages/h3blast/, six unreferenced scripts inscripts/,scripts/buildkite.tsgetLastSuccessfulBuild, thefixturesfeature ofbun_react_compiler, the visualizer topics of the bake dev server.