Skip to content

Remove dead code from shell, bake dev server, sql, install, cli, css, and websocket client - #37229

Merged
Jarred-Sumner merged 8 commits into
mainfrom
claude/farm/8d84b043/dead-code-shell-bake-sql-install
Aug 11, 2026
Merged

Remove dead code from shell, bake dev server, sql, install, cli, css, and websocket client#37229
Jarred-Sumner merged 8 commits into
mainfrom
claude/farm/8d84b043/dead-code-shell-bake-sql-install

Conversation

@robobun

@robobun robobun commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

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 (every ChildPtr::new passes Builtin/Cmd/CondExpr; subprocess capture uses Subproc), so their dispatch arms and the two on_io_writer_chunk handlers reachable only through them were unreachable.
  • Never-assigned states: SubshellState::{Expanding,WaitWriteErr}, IfState::{WaitingWriteErr,Done} (the Done arm was panic!("This code should not be reachable")), CondExprState::Done, CatState::Done (plus the local Branch::Done it fed).
  • Yield::Start (spawners call interp.start_node() directly), ParseFlagResult::ShowUsage (no FlagParser impl returns it), EntryKindHint::File (rm constructs only Idk/Dir).

bake dev server

  • route_bundle::State::EvaluationFailure was never constructed. Deleted its arm, both EnsureRouteCtx::on_failure impls (which would have unwraped the always-None Framework.evaluate_failure field), the field, and ErrorPageKind (every live caller passed Bundler, so the page title is now a constant).
  • MessageId::{BrowserMessage,BrowserMessageClear,RequestHandlerError}: wire bytes the server never sends and no client handles. generated.ts regenerated 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 as as u8 in packet writers, no decode path.
  • mysql StatusFlag: kept SERVER_MORE_RESULTS_EXISTS (the only flag StatusFlags::has is asked about). Decode is unaffected; StatusFlags stores the raw u16.
  • Never-constructed error variants and their arms: mysql InvalidState, postgres InvalidByteSequenceForEncoding and InvalidTimeFormat. These names are also not producible via the EnumString reverse parse in From<crate::Error> (no other sql error enum carries them). Postgres Overflow stays: mysql's constructed Overflow could reach it through that by-name parse.

install / cli

  • Subcommand::Scan plus its two arms (28 lines of help text): bun pm scan dispatches under Subcommand::Pm.
  • Step::{Copyfile,Linking,Patching}: InstallResult::fail is only called with the other four variants.
  • The lifecycle script time log: the entry struct was empty, the list was never read, and the timer field feeding it was never set to Some, so the whole chain (structs, append_concurrent, the PackageManager field, the timer field, manager_mut) was a write-only no-op left from the port.
  • PackageInstall.file_count carried 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) and ExampleTag::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 live CSSPrintError spellings are the separate PrintErr enum) and two uncalled inherent parse_with_options helpers on GenericSelectorList/GenericSelector.
  • websocket ErrorCode::{HeadersTooLarge,CompressionFailed,ExpectedControlFrame,ProtocolError,ProxyConnectionRefused}: never constructed. Discriminants are explicit, so the remaining values still line up with the C++ WebSocketErrorCode table.
  • WTFTimer__runIfImminent: an extern "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_ready stubs with no callers (teardown goes through Subprocess::on_close_io and the UpstreamSource impl).
  • fs-watcher EventType::Abort was never sent (C++ EventNames.cpp keeps 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_router and bundler's unused bun_router dependency; a dead root re-export in bun_s3_signing.

Verification

  • cargo check via bun run rust:check-all: 10 ok, 0 failed.
  • Full bun bd debug build.
  • bun bd test on 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 named bun), identical under the released bun.
  • Adds test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts pinning 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)

… subprocess

All items verified to have zero references across src/, scripts/, packages/,
and regenerated build/debug/codegen output, then validated by cargo check and
a full debug build.

- shell: WriterTag::{Pipeline,Subshell,If} were never constructed; deleted
  the variants, their dispatch arms, and the two on_io_writer_chunk handlers
  only reachable through them. Also removed never-assigned states
  (SubshellState::{Expanding,WaitWriteErr}, IfState::{WaitingWriteErr,Done},
  CondExprState::Done, CatState::Done), Yield::Start,
  ParseFlagResult::ShowUsage, and EntryKindHint::File.
- bake: route_bundle::State::EvaluationFailure was never constructed; deleted
  the EnsureRouteCtx::on_failure chain, the always-None
  Framework.evaluate_failure field, and ErrorPageKind (now a constant).
  Dropped MessageId::{BrowserMessage,BrowserMessageClear,RequestHandlerError}
  wire bytes the server never sent (generated.ts regenerated).
- sql: 28 unsent mysql CommandType variants, 13 unread StatusFlag variants,
  and never-constructed error variants (mysql InvalidState, postgres
  InvalidByteSequenceForEncoding/InvalidTimeFormat) with their arms.
- install: Subcommand::Scan (bun pm scan dispatches under Subcommand::Pm),
  Step::{Copyfile,Linking,Patching}, the write-only lifecycle script time
  log (empty entry struct, list never read, feeding timer always None), and
  the file_count field flagged 'this is never read'.
- cli: PackError::MissingPackageJSON (never constructed) and
  ExampleTag::Unknown (zero references).
- css: never-constructed crate_error::Error::CSSPrintError and two uncalled
  inherent parse_with_options helpers.
- websocket: five never-constructed ErrorCode variants (explicit
  discriminants keep the remaining C++ table values stable).
- subprocess/timer/watcher: uncalled Readable/Writable stubs, the orphan
  WTFTimer__runIfImminent extern, and the never-sent fs-watcher
  EventType::Abort.
- C++: KeyObject::getKeyObjectFromHandle decl+def pair with zero callers.
- js: two unread repl util-shim constants and a write-only minimatch debug
  property.
- Cargo.toml: unused deps in bun_glob/bun_router and bundler's unused
  bun_router dependency.

Adds a source lint pinning every removal so the symbols do not reappear.
@robobun

robobun commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 3:42 PM PT - Aug 11th, 2026

@Jarred-Sumner, your commit fc75209 is building: #92526

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The pull request removes unused dependencies, obsolete public symbols, dead runtime paths, and redundant state transitions across installation, runtime, protocol, CSS, JavaScript, and C++ code. It adds source-lint coverage for removed symbols.

Changes

Dead code cleanup

Layer / File(s) Summary
Installation and package-manager cleanup
src/install/...
Removed package-install file-count tracking, obsolete installation steps, lifecycle timing logs, and the Scan subcommand.
Bake route-bundling cleanup
src/runtime/bake/...
Removed evaluation-failure states, callbacks, error-page distinctions, and related serialized failure data.
Shell state-machine cleanup
src/runtime/shell/...
Removed unused continuation, writer, completion, and suspended-state variants and callbacks.
Protocol and runtime API cleanup
src/css/..., src/http_jsc/..., src/runtime/cli/..., src/runtime/node/..., src/sql/..., src/sql_jsc/...
Removed obsolete parser helpers, protocol variants, error mappings, CLI errors, and filesystem event variants.
Remaining cleanup and validation
src/*/Cargo.toml, src/js/..., src/jsc/..., test/internal/source-lints/...
Removed unused dependencies and helpers, then added source-lint coverage for deleted symbols.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description explains the dead-code removals and provides detailed verification results, including builds, tests, CI checks, and known environment-specific failures.
Title check ✅ Passed The title clearly summarizes the primary change by identifying dead-code removal across the main affected components.

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

@robobun

robobun commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

The head change that interrupted the review was a one-line reword of a comment in the new source-lint test (no code change); 5c248cc is otherwise identical to c9ec5af. CI is running against the new head.

@robobun

robobun commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

This interruption was autofix-ci's formatting commit (e6fd605: two collapsed blank lines from rustfmt, one prettier line wrap in the lint test). No functional changes; CI is running against that head.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/install/PackageInstall.rs`:
- Around line 1099-1101: Update the copy helper functions used by the call sites
around copy, including the additional referenced sections, to return
crate::Result<()> instead of crate::Result<u32>. Remove real_file_count and all
increments, and return Ok(()) after successful copying while preserving existing
error propagation and InstallResult handling.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c5fc7bf8-5212-4330-91ac-b5fa0b12ce77

📥 Commits

Reviewing files that changed from the base of the PR and between 9008ae7 and e6fd605.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (44)
  • src/bundler/Cargo.toml
  • src/css/crate_error.rs
  • src/css/selectors/parser.rs
  • src/glob/Cargo.toml
  • src/http_jsc/websocket_client.rs
  • src/install/PackageInstall.rs
  • src/install/PackageInstaller.rs
  • src/install/PackageManager.rs
  • src/install/PackageManager/CommandLineArguments.rs
  • src/install/PackageManager/PackageManagerLifecycle.rs
  • src/install/lifecycle_script_runner.rs
  • src/install/patch_install.rs
  • src/js/internal/fs/glob.ts
  • src/js/internal/repl/node-shims.js
  • src/jsc/bindings/node/crypto/KeyObject.cpp
  • src/jsc/bindings/node/crypto/KeyObject.h
  • src/router/Cargo.toml
  • src/runtime/api/bun/subprocess/Readable.rs
  • src/runtime/api/bun/subprocess/Writable.rs
  • src/runtime/bake/DevServer.rs
  • src/runtime/bake/dev_server/mod.rs
  • src/runtime/bake/dev_server/route_bundle.rs
  • src/runtime/cli/create_command.rs
  • src/runtime/cli/pack_command.rs
  • src/runtime/cli/publish_command.rs
  • src/runtime/node/node_fs_watcher.rs
  • src/runtime/shell/IOWriter.rs
  • src/runtime/shell/Yield.rs
  • src/runtime/shell/builtin/cat.rs
  • src/runtime/shell/builtin/rm.rs
  • src/runtime/shell/interpreter.rs
  • src/runtime/shell/states/CondExpr.rs
  • src/runtime/shell/states/If.rs
  • src/runtime/shell/states/Pipeline.rs
  • src/runtime/shell/states/Subshell.rs
  • src/runtime/timer/WTFTimer.rs
  • src/s3_signing/lib.rs
  • src/sql/mysql/StatusFlags.rs
  • src/sql/mysql/protocol/AnyMySQLError.rs
  • src/sql/mysql/protocol/CommandType.rs
  • src/sql/postgres/AnyPostgresError.rs
  • src/sql_jsc/mysql/protocol/any_mysql_error_jsc.rs
  • src/sql_jsc/postgres/error_jsc.rs
  • test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts
💤 Files with no reviewable changes (36)
  • src/js/internal/fs/glob.ts
  • src/sql/mysql/protocol/AnyMySQLError.rs
  • src/bundler/Cargo.toml
  • src/sql/mysql/protocol/CommandType.rs
  • src/sql_jsc/mysql/protocol/any_mysql_error_jsc.rs
  • src/runtime/timer/WTFTimer.rs
  • src/js/internal/repl/node-shims.js
  • src/runtime/shell/states/Pipeline.rs
  • src/jsc/bindings/node/crypto/KeyObject.h
  • src/install/PackageManager/CommandLineArguments.rs
  • src/jsc/bindings/node/crypto/KeyObject.cpp
  • src/install/PackageManager/PackageManagerLifecycle.rs
  • src/css/crate_error.rs
  • src/install/PackageInstaller.rs
  • src/runtime/cli/pack_command.rs
  • src/s3_signing/lib.rs
  • src/runtime/bake/dev_server/mod.rs
  • src/runtime/node/node_fs_watcher.rs
  • src/glob/Cargo.toml
  • src/sql/postgres/AnyPostgresError.rs
  • src/runtime/shell/Yield.rs
  • src/runtime/shell/states/If.rs
  • src/sql_jsc/postgres/error_jsc.rs
  • src/runtime/api/bun/subprocess/Writable.rs
  • src/css/selectors/parser.rs
  • src/http_jsc/websocket_client.rs
  • src/runtime/shell/states/CondExpr.rs
  • src/runtime/cli/publish_command.rs
  • src/sql/mysql/StatusFlags.rs
  • src/runtime/bake/dev_server/route_bundle.rs
  • src/runtime/api/bun/subprocess/Readable.rs
  • src/runtime/cli/create_command.rs
  • src/runtime/shell/interpreter.rs
  • src/router/Cargo.toml
  • src/install/lifecycle_script_runner.rs
  • src/install/patch_install.rs

Comment thread src/install/PackageInstall.rs
The counts' only consumer was the file_count field removed earlier; the
copy helpers now return Result<()>.
Comment thread test/internal/source-lints/dead-symbols-shell-bake-sql-install.test.ts Outdated
Comment thread src/install/lifecycle_script_runner.rs Outdated
Comment thread src/http_jsc/websocket_client.rs
robobun and others added 3 commits August 9, 2026 05:52
The five enum entries and their switch arms in WebSocket.cpp were
unreachable: the Rust client never sent those discriminants.
@robobun

robobun commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI status for merge review: build 90794 finished with 195 of 196 jobs passing. The single red job is ":darwin: 26 aarch64 - test-bun", which dies before any test runs (tart guest VM ssh auth failure, exit 255); the same pre-existing runner issue hit the previous build on a different host (darwin 14 aarch64), so it is independent of this diff and has been reported to CI infra. All test-level failures in both builds were known-flaky tests that passed on retry or when run alone; the two that stayed red in the first build (worker-transfer-terminate-stress on x64-asan, napi.test.ts on darwin x64) are pre-existing on main and were reported separately, and both passed in this build.

The diff itself is green everywhere it ran: lints, clippy, miri, all build lanes, and every test lane except the broken darwin runner. Review feedback is addressed and all threads resolved. Ready for a maintainer.

@Jarred-Sumner
Jarred-Sumner merged commit ee86e41 into main Aug 11, 2026
8 of 10 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/farm/8d84b043/dead-code-shell-bake-sql-install branch August 11, 2026 22:42
Change = 1,
Error = 2,
Abort = 3,
Close = 4,

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.

🟡 The C++ mirror of this enum still declares the removed variant: EventNames.cpp:50 (abort = 3,) and its switch arm at EventNames.cpp:65-66. Bun__domEventNameToJS's only caller is node_fs_watcher.rs:348 passing this Rust EventType, so DOMEventName is a 1:1 FFI mirror — the same half-prune pattern flagged for WebSocket ErrorCode/WebSocketErrorCode and fixed in b2ce4d9. Nothing breaks (Close = 4 keeps its explicit discriminant on both sides); flagging for consistency with that fix. Fix: delete abort = 3, and its case DOMEventName::abort: arm (the eventNames().abortEvent string itself is used elsewhere and should stay).

Extended reasoning...

What

The PR removes EventType::Abort = 3 from src/runtime/node/node_fs_watcher.rs:343 but leaves its C++ mirror in place:

  • src/jsc/bindings/webcore/EventNames.cpp:50abort = 3, in enum class DOMEventName
  • src/jsc/bindings/webcore/EventNames.cpp:65-66case DOMEventName::abort: return eventNames().abortEvent;

Why DOMEventName is a 1:1 FFI mirror of EventType

Bun__domEventNameToJS (EventNames.cpp:55) has exactly one caller in the entire tree: node_fs_watcher.rs:348, which passes the Rust EventType enum as its name argument (verified by grep across src/ — the only hits are the extern "C" definition, the Rust FFI import at node_fs_watcher.rs:353, and the call site at :348). The C++ DOMEventName enum exists solely to give that function a typed switch over the discriminants Rust sends; it has the same five entries with the same explicit values (rename=0, change=1, error=2, abort=3, close=4). This is a mirrored table across the FFI boundary.

Why REVIEW.md applies

REVIEW.md, Correctness: the bug class, not the bug: "Fix the whole class in the same PR (same-class sites are ONE concern, not scope creep). Grep for every sibling site sharing the pattern." And One source of truth; update every consumer atomically: "When a fact lives in two places (mirrored tables, encode/decode pairs), derive one from the other."

This is byte-for-byte the same half-prune pattern that was flagged for the WebSocket ErrorCode/WebSocketErrorCode mirror during this PR's own review and fixed in commit b2ce4d9 (which removed the five orphaned entries from WebSocketErrorCode.h and their switch arms from WebSocket.cpp). The PR description's parenthetical — "C++ EventNames.cpp keeps its by-value string table entry" — is the same defense the WebSocket case had before b2ce4d9 overruled it. The fs-watcher mirror is another instance of the same class the PR already swept.

Why this is nit, not normal

Nothing breaks. Close = 4 keeps its explicit discriminant on both the Rust and C++ sides, so the remaining live values still line up byte-for-byte. Rust never sends 3 anymore, so the C++ case DOMEventName::abort: arm is unreachable — it was already unreachable before this PR (the Rust variant was never constructed), and the PR just made the desync explicit. Merging as-is causes zero behavioral change; this is purely a consistency issue with the WebSocket fix already applied in this PR.

Step-by-step proof

  1. Before this PR: Rust EventType::Abort = 3 exists at node_fs_watcher.rs:343 but is never constructed (per the PR's own word-boundary sweep). C++ DOMEventName::abort = 3 exists at EventNames.cpp:50 with a switch arm at :65-66 — unreachable, since Rust never sends 3.
  2. This PR deletes the Rust Abort = 3 line. C++ abort = 3 and its switch arm remain — still unreachable, now with no Rust counterpart at all.
  3. The next Rust variant, Close = 4, keeps its explicit discriminant and still matches C++ close = 4 (EventNames.cpp:51). Every live discriminant Rust can send (0,1,2,4) still hits the correct C++ case.
  4. Bun__domEventNameToJS has no other caller (grep confirms), so no other code path can reach the abort arm.

Fix

Delete abort = 3, from the DOMEventName enum (EventNames.cpp:50) and its case DOMEventName::abort: switch arm (EventNames.cpp:65-66). Do not touch eventNames().abortEvent itself — that AtomString is part of the WebCore event-name registry and is used elsewhere (AbortSignal etc.); only the fs-watcher-specific DOMEventName enum entry and its case arm are dead. Optionally extend the guard test's C++ section to cover EventNames.cpp the same way b2ce4d9 extended it for WebSocketErrorCode.h/WebSocket.cpp.

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