Remove dead code from shell, bake dev server, sql, install, cli, css, and websocket client
Removes 477 lines of verified-dead code across the shell interpreter, bake dev server, SQL wire protocol, package manager, CLI, CSS, websocket client, subprocess glue, and build config (net -436 after the guard lint).
Every deletion was verified with word-boundary searches across src/, scripts/, packages/, and regenerated build/debug/codegen/ output (including C++ callers, $zig/$cpp string references, and EnumString by-name reverse parses), then validated by cargo check on all 10 CI target triples and a full debug build. The workspace denies dead_code, so what survives the lint is mostly never-constructed pub enum variants and the unreachable chains behind their match arms; that is what this PR removes.
shell interpreter
WriterTag::{Pipeline,Subshell,If}were never constructed (everyChildPtr::newpassesBuiltin/Cmd/CondExpr; subprocess capture usesSubproc), so their dispatch arms and the twoon_io_writer_chunkhandlers reachable only through them were unreachable.- Never-assigned states:
SubshellState::{Expanding,WaitWriteErr},IfState::{WaitingWriteErr,Done}(theDonearm waspanic!("This code should not be reachable")),CondExprState::Done,CatState::Done(plus the localBranch::Doneit fed). Yield::Start(spawners callinterp.start_node()directly),ParseFlagResult::ShowUsage(noFlagParserimpl returns it),EntryKindHint::File(rm constructs onlyIdk/Dir).
bake dev server
route_bundle::State::EvaluationFailurewas never constructed. Deleted its arm, bothEnsureRouteCtx::on_failureimpls (which would haveunwraped the always-NoneFramework.evaluate_failurefield), the field, andErrorPageKind(every live caller passedBundler, so the page title is now a constant).MessageId::{BrowserMessage,BrowserMessageClear,RequestHandlerError}: wire bytes the server never sends and no client handles.generated.tsregenerated via the bake codegen.
sql
- mysql
CommandType: kept the three commands bun sends (COM_QUERY,COM_STMT_PREPARE,COM_STMT_EXECUTE); the other 28 had zero references. The enum is only used asas u8in packet writers, no decode path. - mysql
StatusFlag: keptSERVER_MORE_RESULTS_EXISTS(the only flagStatusFlags::hasis asked about). Decode is unaffected;StatusFlagsstores the rawu16. - Never-constructed error variants and their arms: mysql
InvalidState, postgresInvalidByteSequenceForEncodingandInvalidTimeFormat. These names are also not producible via theEnumStringreverse parse inFrom<crate::Error>(no other sql error enum carries them). PostgresOverflowstays: mysql's constructedOverflowcould reach it through that by-name parse.
install / cli
Subcommand::Scanplus its two arms (28 lines of help text):bun pm scandispatches underSubcommand::Pm.Step::{Copyfile,Linking,Patching}:InstallResult::failis only called with the other four variants.- The lifecycle script time log: the entry struct was empty, the list was never read, and the
timerfield feeding it was never set toSome, so the whole chain (structs,append_concurrent, thePackageManagerfield, the timer field,manager_mut) was a write-only no-op left from the port. PackageInstall.file_countcarried a literal "TODO: this is never read" comment; error handling at the four assignment sites is preserved.PackError::MissingPackageJSON(never constructed; the live same-named variants are on different enums) andExampleTag::Unknown(zero references; the compiler confirmed by flagging the_ => unreachable!()arm as unreachable once it was gone).
css / websocket / subprocess / timer / watcher / C++ / js
- css
crate_error::Error::CSSPrintError(never constructed; the liveCSSPrintErrorspellings are the separatePrintErrenum) and two uncalled inherentparse_with_optionshelpers onGenericSelectorList/GenericSelector. - websocket
ErrorCode::{HeadersTooLarge,CompressionFailed,ExpectedControlFrame,ProtocolError,ProxyConnectionRefused}: never constructed. Discriminants are explicit, so the remaining values still line up with the C++WebSocketErrorCodetable. WTFTimer__runIfImminent: anextern "C"export with zero references in C++, vendor/WebKit, or codegen (the imminent-GC path runs via__bun_run_wtf_timer).- Subprocess
Readable::{on_close,on_ready}/Writable::on_readystubs with no callers (teardown goes throughSubprocess::on_close_ioand theUpstreamSourceimpl). - fs-watcher
EventType::Abortwas never sent (C++EventNames.cppkeeps its by-value string table entry). - C++
KeyObject::getKeyObjectFromHandle: declaration + definition pair with zero callers. - js: two unread repl
internalBinding('util')shim constants and a write-only minimatch debug property. - Cargo.toml: unused boilerplate deps in
bun_glob/bun_routerand bundler's unusedbun_routerdependency; a dead root re-export inbun_s3_signing.
Verification
cargo checkviabun run rust:check-all: 10 ok, 0 failed.- Full
bun bddebug build. bun bd teston the touched areas:bunshell.test.ts(418 pass), shell command tests,bun-pack.test.ts(76 pass),bun-install-lifecycle-scripts.test.ts(115 pass), websocket permessage-deflate,css.test.ts(1209 pass),bake/dev/esm.test.ts,repl.test.ts(148 pass),glob/match.test.ts,fs.watch.test.ts, spawn exit-code/stream tests. The only local failures are container artifacts (tests running as root, tests hitting external websocket endpoints, and PATH shims that expect a binary literally namedbun), identical under the released bun.- Adds
test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.tspinning every removal so the symbols do not come back.
Follow-up note (not in this diff): bun_install::npm decodes a manifest file_count that may also be write-only, and the shell PromptBehaviour::Once { removed_count } field is written but unread pending -i support; both left alone as plausible in-flight scaffolding.
[review] gate passed · iteration 3 · 47 files touched
fails on main (without fix)
ASAN without fix: 5 FAILED
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts
bun test v1.4.0 (c5c1ab8a7)
test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts:
65 | ["src/runtime/shell/interpreter.rs", /ParseFlagResult::ShowUsage/],
66 | // EntryKindHint::File: rm constructs only Idk and Dir.
67 | ["src/runtime/shell/builtin/rm.rs", /EntryKindHint::File/],
68 | ];
69 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
70 | expect(resurrected).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "src/runtime/shell/IOWriter.rs: ^\s*Pipeline,$",
+ "src/runtime/shell/IOWriter.rs: ^\s*Subshell,$",
+ "src/runtime/shell/states/Pipeline.rs: fn on_io_writer_chunk",
+ "src/runtime/shell/states/Subshell.rs: fn on_io_writer_chunk",
+ "src/runtime/shell/states/Subshell.rs: \bExpanding\b",
+ "src/runtime/shell/states/Subshell.rs: \bWaitWriteErr\b",
+ "src/runtime/shell/states/If.rs: \bWaitingWriteEr
... (truncated)
release without fix: 5 FAILED
bun test v1.4.0-canary.1 (a62a49a95)
test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts:
65 | ["src/runtime/shell/interpreter.rs", /ParseFlagResult::ShowUsage/],
66 | // EntryKindHint::File: rm constructs only Idk and Dir.
67 | ["src/runtime/shell/builtin/rm.rs", /EntryKindHint::File/],
68 | ];
69 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
70 | expect(resurrected).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "src/runtime/shell/IOWriter.rs: ^\s*Pipeline,$",
+ "src/runtime/shell/IOWriter.rs: ^\s*Subshell,$",
+ "src/runtime/shell/states/Pipeline.rs: fn on_io_writer_chunk",
+ "src/runtime/shell/states/Subshell.rs: fn on_io_writer_chunk",
+ "src/runtime/shell/states/Subshell.rs: \bExpanding\b",
+ "src/runtime/shell/states/Subshell.rs: \bWaitWriteErr\b",
+ "src/runtime/shell/states/If.rs: \bWaitingWriteErr\b",
+ "src/runtime/shell/states/CondExpr.rs: ^\s*Done,$",
+ "src/runtime/shell/builtin/cat.rs: CatState::Done",
+ "src/runtime/shell/Yield.rs: \bStart\(NodeId\)",
+ "src/runtime/shell/i
... (truncated)
passes on PR (with fix)
ASAN with fix: all passed
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts
bun test v1.4.0 (c5c1ab8a7)
test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts:
(pass) dead shell interpreter symbols do not reappear [31.32ms]
(pass) dead bake dev server symbols do not reappear [13.81ms]
(pass) dead SQL wire-protocol enum variants do not reappear [10.18ms]
(pass) dead install/cli symbols do not reappear [23.29ms]
(pass) dead websocket/timer/subprocess/watcher/css symbols do not reappear [15.19ms]
(pass) dead C++/JS symbols do not reappear (committed tree) [34.75ms]
6 pass
0 fail
16 expect() calls
Ran 6 tests across 1 file. [2.52s]
__F:0:S:0
release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 634ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/32] gen bake.{client,server,error}.js
-> bake.client.js, bake.server.js, bake.error.js
[2/32] gen generated_host_exports.rs
generated_host_exports.rs: 93 exports (host=3, lazy=10, generic=80, rust=0); 239 extern-C blocks audited
[3/32] gen cpp.rs (cppbind)
[4/32] gen JS modules (bundle-modules)
Preprocess modules (8785ms)
Bundle modules (35ms)
Postprocesss modules (215ms)
Bundle Functions (686ms)
Generate Code (27ms)
[9.76s] Bundled "src/js" for production
2610 kb
197 internal modules
13 native modules
91 internal functions across 17 files
[4/23] cargo bun_bin → libbun_rust.a (--target x86_64-unknown-linux-gnu)
nightly-2026-07-20-x86_64-unknown-linux-gnu unchanged - rustc 1.99.0-nightly (9f36de775 2026-07-19)
[1m[92m Compiling[0m bun_core v0.0.0 (/workspace/bun/src/bun_core)
[1m[92m Compiling[0m bun_errno v0.0.0 (/workspace/bun/src/errno)
[1m[92m Compiling[0m bun_ptr v0.0.0 (/workspace/bun/src/ptr)
[1m[92m Compiling[0m bun_boringssl_sys v0.0.0 (/workspace/bun/src/borin
... (truncated)
diff hotspot
Cargo.lock | 12 --
src/bundler/Cargo.toml | 1 -
src/css/crate_error.rs | 3 -
src/css/selectors/parser.rs | 21 ---
src/glob/Cargo.toml | 6 -
src/http_jsc/websocket_client.rs | 5 -
src/install/PackageInstall.rs | 117 +++++-------
src/install/PackageInstaller.rs | 1 -
src/install/PackageManager.rs | 11 +-
src/install/PackageManager/CommandLineArguments.rs | 26 ---
.../PackageManager/PackageManagerLifecycle.rs | 17 --
src/install/lifecycle_script_runner.rs | 30 ---
src/install/patch_install.rs | 1 -
src/js/internal/fs/glob.ts | 1 -
src/js/internal/repl/node-shims.js | 4 -
src/jsc/bindings/node/crypto/KeyObject.cpp | 19 --
src/jsc/bindings/node/crypto/KeyObject.h | 1 -
src/jsc/bindings/webcore/WebSocket.cpp | 20 --
src/jsc/bindings/webcore/WebSocketErrorCode.h | 5 -
src/router/Cargo.toml | 5 -
src/runtime/api/bun/subprocess/Readable.rs | 7 -
src/runtime/api/bun/subprocess/Writable.rs | 2 -
src/runtime/bake/DevServer.rs | 86 +--------
src/runtime/bake/dev_server/mod.rs | 3 -
src/runtime/bake/dev_server/route_bundle.rs | 4 -
src/runtime/cli/create_command.rs | 2 -
src/runtime/cli/pack_command.rs | 9 -
src/runtime/cli/publish_command.rs | 6 -
src/runtime/node/node_fs_watcher.rs | 1 -
src/runtime/shell/IOWriter.rs | 15 +-
src/runtime/shell/Yield.rs | 4 -
src/runtime/shell/builtin/cat.rs | 6 +-
src/runtime/shell/builtin/rm.rs
... (truncated)
gate history · 2 passed · 1 rejected · iteration 3
evidence per changed file
file reads edits tests
Cargo.lock 0 0 0
src/bundler/Cargo.toml 1 1 0
src/css/crate_error.rs 1 1 0
src/css/selectors/parser.rs 1 1 0
src/glob/Cargo.toml 1 1 0
src/http_jsc/websocket_client.rs 1 2 0
src/install/PackageInstall.rs 10 9 0
src/install/PackageInstaller.rs 0 0 0
src/install/PackageManager.rs 1 3 0
src/install/PackageManager/CommandLineArguments.rs 1 1 0
src/install/PackageManager/PackageManagerLifecycle.rs 1 1 0
src/install/lifecycle_script_runner.rs 2 3 0
src/install/patch_install.rs 0 0 0
src/js/internal/fs/glob.ts 1 1 0
src/js/internal/repl/node-shims.js 1 1 0
src/jsc/bindings/node/crypto/KeyObject.cpp 1 1 0
(+ 31 more files)