Skip to content

Remove dead code from install, webcore, jsc, sha_hmac, and misc crates - #37089

Open
robobun wants to merge 4 commits into
mainfrom
claude/farm/9c2dbd28/dead-code-sweep-misc
Open

Remove dead code from install, webcore, jsc, sha_hmac, and misc crates#37089
robobun wants to merge 4 commits into
mainfrom
claude/farm/9c2dbd28/dead-code-sweep-misc

Conversation

@robobun

@robobun robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Dead code sweep over areas not covered by the open dead-code PRs (#37062, #37012, #36237, #36115, #35880, #35775, #35437): install, runtime/node, runtime/webcore, jsc, sql_jsc, and the sha_hmac/wyhash/clap/md/errno/spawn/api/bundler_jsc leaf crates, plus scripts/build. Net -250 lines. No overlap with the deletions in any open PR (the only shared file, headers-handwritten.h, is touched on different lines).

Every removal was verified by rg across src/, src/codegen/, src/js/, and build/debug/codegen/ (zero references outside the definition), then by compiling.

Removed

install: CacheBehavior enum and parameter. The LoadFromMemory variant is never constructed anywhere, so every one of the 8 call sites passes LoadFromMemoryFallbackToDisk and the enum carries no information. Removed the enum, the cache_behavior parameter from the four by_name* lookups, the dead memory-only branch in by_name_hash_allow_expired, the ManifestLoad re-exports, and the argument at all call sites (outdated, update-interactive, lockfile, enqueue, populate-manifest-cache). The memory-only path callers actually use is by_name_hash_in_memory, which stays. Also removed the unused pub use patch_install as patch; alias (all consumers use patch_install:: directly).

runtime/node: Bun__versions_uws / Bun__versions_usockets. These no_mangle statics (and their extern "C" declarations in headers-handwritten.h) have no readers: BunProcess.cpp reads BUN_VERSION_USOCKETS/BUN_VERSION_UWS from the generated bun_dependency_versions.h since #22561. Their values were wrong anyway (both held the bun git sha). Since all C++ references resolve at link time, the full bun bd link passing is the proof nothing consumes the symbols.

jsc: error-code sentinels and dangerously_set_ptr. Zig_ErrorCodeParserError is declared in headers-handwritten.h but no C++ reads it; Zig_ErrorCodeJSErrorObject is not even declared. Removed both statics, the declaration, and the PARSER_ERROR const whose only use they were (JS_ERROR_OBJECT stays, it is used widely). Separately, the js_class_module! macro emitted a dangerously_set_ptr wrapper plus its __dangerouslySetPtr extern import in every instantiation, and no instantiation calls it; the similarly named symbols in build codegen belong to generate-classes.ts's own separate Rust surface, which declares its own externs.

webcore: never-constructed variants. StartTag::{Empty, Err, ChunkSize, Ready, OwnedAndDone, Done} are never constructed (only the 8 sink tags are used as START_TAG consts and const-generic args), so the two fallback _ arms they fed were unreachable and are gone too; the remaining matches are exhaustive. ReadDuringJSOnPullResult::AmountRead is never produced by on_read_chunk (the code already said so in a comment).

sha_hmac. The deprecated-OpenSSL3 sha::hashers module has exactly two consumers: SHA1 (websocket upgrade) and SHA256 (s3 signing). Removed the unused SHA512, SHA384, SHA512_256, RIPEMD160 hashers. CryptoHasher's hashers::SHA384 etc. resolve through its use bun_sha_hmac::sha as hashers; alias to the evp re-exports, which stay. Also removed evp::MD5_SHA1 and evp::Blake2 (zero references; Algorithm::Blake2b256 calls ffi::EVP_blake2b256() directly).

Smaller items.

  • wyhash: HashInt impls for u16/u64; the single hash_int caller passes u32.
  • clap: Error::WriteFailed is never constructed (no fallible-fmt path converts into it); removed the variant, its From<fmt::Error> impl, and the unreachable diagnostic arm.
  • md: LineType::Setextheader never constructed or matched.
  • react_compiler: private default_true helper with zero references.
  • Unused re-export names (each verified unreferenced under the re-exported path): sql_jsc SslConfig alias and the CoerceTo/ExternColumnIdentifierValue/ThrowFmtArgs/ZigStringJsc facade tokens; bun_api NodeLinker/NpmRegistryMap/PnpmMatcher; bundler_jsc FsPath/ErrorableString/JsError; errno Mode alias (all three platform files); spawn BunSpawn/PosixSpawn aliases; runtime/ffi abi_type surface (formatters narrowed to pub(crate), matching the workspace unreachable_pub convention) and runtime/valkey_jsc surface trims.
  • scripts/build: the "src/*.c" glob (its last match, src/asan-config.c, was deleted in asan: keep MarkedArgumentBuffer inline storage on the real stack #29655; the pattern silently matches nothing), the write-only #define BUN_DEP_* block in the generated versions header (BunProcess.cpp reads only the BUN_VERSION_* constants), and the Config.kqueue field (computed, stored, never read).

Verification

  • cargo check -p bun_bin clean
  • bun bd full build and link passes (link success is the decisive check for the removed no_mangle statics)
  • bun run rust:check-all: 10 ok, 0 failed (no platform-gated false positives)
  • bunx tsc -p scripts/build/tsconfig.json: same 18 pre-existing errors with and without this diff, none in touched files
  • Smoke tests in touched areas: bun-cryptohasher (400 pass), arraybuffersink (13), markdown-entrypoint (30), minimum-release-age (49, exercises the manifest-cache paths), update-interactive-formatting (5)

Verified dead but deliberately left in place

These have zero references today but carry explicit staging markers or ABI roles, so they are notes rather than deletions: the h2 Connection outbound-send API (module-level allow(dead_code), unit-tested), react_compiler's logger/diagnostic parity types (allow with upstream-parity reasons), bun_opaque::FfiLayout (documented sealed marker), bake's State::EvaluationFailure/BakeProdSourceMap (receiving ends of not-yet-wired dev-server and SSG paths; removing them strands live plumbing), BOM::Utf16Be/Utf32* (detection intentionally not ported yet), PercentEncodeError::OutOfMemory (staged for fallible-alloc), dev-server MessageId wire ids, and the RegularExpression::Flags / SSRKind::Regular ABI mirrors.


[review] gate passed · iteration 1 · 38 files touched

fails on main (without fix)
ASAN without fix: 3 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-install-webcore-sha.test.ts
bun test v1.4.0 (f9fc3ccc6)

test/internal/source-lints/dead-symbols-install-webcore-sha.test.ts:
70 |     ["src/md/types.rs", /Setextheader/],
71 | 
72 |     // react_compiler: zero references.
73 |     ["src/react_compiler/hir/environment_config.rs", /fn default_true\b/],
74 |   ];
75 |   expect(resurrected(checks)).toEqual([]);
                                   ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/install/PackageManifestMap.rs: pub enum CacheBehavior\b",
+   "src/runtime/node/node_process.rs: static Bun__versions_uws:",
+   "src/runtime/node/node_process.rs: static Bun__versions_usockets:",
+   "src/jsc/ErrorCode.rs: static Zig_ErrorCodeParserError:",
+   "src/jsc/ErrorCode.rs: static Zig_ErrorCodeJSErrorObject:",
+   "src/jsc/ErrorCode.rs: const PARSER_ERROR: ErrorCodeInt",
+   "src/jsc/generated.rs: __dangerouslySetPtr",
+   "src/runtime/webcore/streams.rs: pub enum StartTag \{[^}]*OwnedAndDone",
+   "src/runtime/webcore/FileReader.rs: A
... (truncated)

release without fix: 3 FAILED
bun test v1.4.0-canary.1 (962d3f7ff)

test/internal/source-lints/dead-symbols-install-webcore-sha.test.ts:
70 |     ["src/md/types.rs", /Setextheader/],
71 | 
72 |     // react_compiler: zero references.
73 |     ["src/react_compiler/hir/environment_config.rs", /fn default_true\b/],
74 |   ];
75 |   expect(resurrected(checks)).toEqual([]);
                                   ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/install/PackageManifestMap.rs: pub enum CacheBehavior\b",
+   "src/runtime/node/node_process.rs: static Bun__versions_uws:",
+   "src/runtime/node/node_process.rs: static Bun__versions_usockets:",
+   "src/jsc/ErrorCode.rs: static Zig_ErrorCodeParserError:",
+   "src/jsc/ErrorCode.rs: static Zig_ErrorCodeJSErrorObject:",
+   "src/jsc/ErrorCode.rs: const PARSER_ERROR: ErrorCodeInt",
+   "src/jsc/generated.rs: __dangerouslySetPtr",
+   "src/runtime/webcore/streams.rs: pub enum StartTag \{[^}]*OwnedAndDone",
+   "src/runtime/webcore/FileReader.rs: AmountRead\(usize\)",
+   "src/sha_hmac/sha.rs: SHA512_Init,\s*\n\s*boringssl_sys::SHA512_Update",
+   "src/sha_hmac/sha.rs: RIPEMD160_Init",
+   "src/sha_hmac/sha.rs: new_evp!\(MD5_SHA1",
+   
... (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-install-webcore-sha.test.ts
bun test v1.4.0 (f9fc3ccc6)

test/internal/source-lints/dead-symbols-install-webcore-sha.test.ts:
(pass) dead Rust symbols (install, webcore, jsc, leaf crates) do not reappear [66.00ms]
(pass) dead C++ header declarations do not reappear [9.82ms]
(pass) unused re-export names do not reappear [39.29ms]
(pass) stale build-script entries do not reappear [10.69ms]

 4 pass
 0 fail
 4 expect() calls
Ran 4 tests across 1 file. [3.38s]
__F:0:S:0

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 928ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/130] esbuild bun-error

  ../../build/release/codegen/bun-error/index.js       42.9kb
  ../../build/release/codegen/bun-error/bun-error.css  12.8kb

⚡ Done in 17ms
[2/130] gen ErrorCode+*.h
[3/130] gen NodeModuleModule.lut.h
Generating /workspace/bun/build/release/codegen/NodeModuleModule.lut.h from /workspace/bun/src/jsc/modules/NodeModuleModule.cpp
[4/130] gen generated_host_exports.rs
generated_host_exports.rs: 92 exports (host=3, lazy=10, generic=79, rust=0); 239 extern-C blocks audited
[5/130] gen cpp.rs (cppbind)
[6/130] gen BunProcess.lut.h
Generating /workspace/bun/build/release/codegen/BunProcess.lut.h from /workspace/bun/src/jsc/bindings/BunProcess.cpp
[7/130] gen JS modules (bundle-modules)
Preprocess modules (15999ms)
Bundle modules (42ms)
Postprocesss modules (43ms)
Bundle Functions (926ms)
Generate Code (28ms)

[17.06s] Bundled "src/js" for production
  2570 kb
  193 internal modules
  13 native modules
  84 internal functions across 17 files
[7/129] cargo bun_bin → libbun_rust.a (--ta
... (truncated)
diff hotspot
scripts/build/config.ts                            |   4 -
 scripts/build/depVersionsHeader.ts                 |   3 -
 scripts/build/source.ts                            |   2 +-
 scripts/glob-sources.ts                            |   1 -
 src/api/lib.rs                                     |   4 +-
 src/bundler_jsc/PluginRunner.rs                    |   2 -
 src/bundler_jsc/lib.rs                             |   2 +-
 src/clap/error.rs                                  |   9 --
 src/clap/lib.rs                                    |   5 -
 src/errno/darwin_errno.rs                          |   1 -
 src/errno/freebsd_errno.rs                         |   1 -
 src/errno/linux_errno.rs                           |   1 -
 .../PackageManager/PackageManagerEnqueue.rs        |   4 +-
 .../PackageManager/PopulateManifestCache.rs        |   3 -
 src/install/PackageManifestMap.rs                  |  45 +-------
 src/install/lib.rs                                 |   7 +-
 src/install/lockfile.rs                            |   1 -
 src/jsc/ErrorCode.rs                               |  12 +-
 src/jsc/bindings/headers-handwritten.h             |   7 --
 src/jsc/generated.rs                               |  22 +---
 src/md/types.rs                                    |   1 -
 src/react_compiler/hir/environment_config.rs       |   4 -
 src/runtime/api/bun/spawn.rs                       |   2 +-
 src/runtime/cli/outdated_command.rs                |   4 +-
 src/runtime/cli/update_interactive_command.rs      |   5 +-
 src/runtime/ffi/abi_type.rs                        |   6 +-
 src/runtime/ffi/mod.rs                             |   1 -
 src/runtime/node/node_process.rs                   |  14 ---
 src/runtime/valkey_jsc/mod.rs                      |   3 +-
 src/runtime/webcore/FileReader.rs                  |  17 +--
 src/runtime/webcore/Response.rs                    |   8 +-
 src/runtime/webcore/streams.rs                     |  13 ---
 src/sha_hmac/lib.rs               
... (truncated)

gate history · 2 passed · 1 rejected · iteration 1

evidence per changed file
file                                                 reads  edits  tests
scripts/build/config.ts                                  1      1      0
scripts/build/depVersionsHeader.ts                       1      1      0
scripts/build/source.ts                                  1      1      0
scripts/glob-sources.ts                                  1      1      0
src/api/lib.rs                                           1      1      0
src/bundler_jsc/PluginRunner.rs                          1      1      0
src/bundler_jsc/lib.rs                                   1      1      0
src/clap/error.rs                                        1      1      0
src/clap/lib.rs                                          1      1      0
src/errno/darwin_errno.rs                                0      0      0
src/errno/freebsd_errno.rs                               0      0      0
src/errno/linux_errno.rs                                 0      0      0
src/install/PackageManager/PackageManagerEnqueue.rs      0      0      0
src/install/PackageManager/PopulateManifestCache.rs      0      0      0
src/install/PackageManifestMap.rs                        3      4      0
src/install/lib.rs                                       1      1      0
(+ 22 more files)

- install: CacheBehavior enum had a never-constructed LoadFromMemory variant,
  leaving one variant threaded through 5 signatures and 8 call sites; removed
  the enum, the parameter, and the dead memory-only branch. Also removed the
  unused patch re-export alias.
- runtime/node: Bun__versions_uws / Bun__versions_usockets no_mangle statics
  and their extern declarations. C++ reads these from the generated
  bun_dependency_versions.h since #22561; nothing references the symbols.
- jsc: Zig_ErrorCodeParserError / Zig_ErrorCodeJSErrorObject statics (declared
  but never read from C++), the PARSER_ERROR sentinel const they carried, and
  the unused dangerously_set_ptr method plus its extern import emitted by
  js_class_module! (no instantiation calls it).
- webcore: 6 never-constructed StartTag variants and the now-unreachable
  fallback arms; never-constructed ReadDuringJSOnPullResult::AmountRead.
- sha_hmac: unused deprecated-API hashers (SHA512, SHA384, SHA512_256,
  RIPEMD160; only SHA1 and SHA256 have callers) and unused evp types
  MD5_SHA1 and Blake2.
- wyhash: HashInt impls for u16/u64; the only caller instantiates u32.
- clap: never-constructed Error::WriteFailed variant, its From impl, and the
  match arms it fed.
- md: never-constructed LineType::Setextheader variant.
- react_compiler: unreferenced default_true helper.
- Unused re-export lines: sql_jsc (SslConfig alias, 4 facade tokens),
  bun_api (NodeLinker, NpmRegistryMap, PnpmMatcher), bundler_jsc
  (FsPath, ErrorableString, JsError), errno (Mode alias on all 3 platforms),
  spawn (BunSpawn / PosixSpawn aliases), runtime/ffi and runtime/valkey_jsc
  surface trims (with pub(crate) narrowing where items stay in-crate).
- build scripts: stale src/*.c glob (asan-config.c was deleted), write-only
  BUN_DEP_* macro block in the generated versions header, unread
  Config.kqueue field.

Verified: rg for each symbol across src/, src/codegen/, src/js/, and
build/debug/codegen/ finds no remaining references; cargo check -p bun_bin,
bun bd (full link), and bun run rust:check-all (10/10 targets) pass; smoke
tests in touched areas pass (bun-cryptohasher 400, arraybuffersink 13,
markdown-entrypoint 30, minimum-release-age 49, update-interactive 5).
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change removes obsolete build fields, generated symbols, public re-exports, cache-mode parameters, runtime states, legacy errors, cryptographic implementations, and unused helper APIs.

Changes

Build declarations and generated versions

Layer / File(s) Summary
Build declarations and generated versions
scripts/build/config.ts, scripts/build/depVersionsHeader.ts, scripts/build/source.ts, scripts/glob-sources.ts
Removes the kqueue configuration field, changes generated dependency declarations to BUN_VERSION_* constants, updates related documentation, and removes the top-level C source glob.

Manifest cache lookup

Layer / File(s) Summary
Unified manifest cache lookup
src/install/PackageManifestMap.rs, src/install/PackageManager/*, src/install/lockfile.rs, src/runtime/cli/*, src/install/lib.rs
Removes CacheBehavior and the ManifestLoad arguments. Manifest lookups use unified cache and disk-fallback behavior. Obsolete package-manager exports are removed.

Public API and utility surface

Layer / File(s) Summary
Public API and utility surface reduction
src/api/lib.rs, src/bun_core/string/immutable.rs, src/bundler_jsc/*, src/errno/*, src/runtime/api/bun/spawn.rs, src/runtime/ffi/*, src/runtime/valkey_jsc/*, src/spawn/lib.rs, src/sql_jsc/jsc.rs, src/md/types.rs
Removes unused public re-exports, aliases, string helpers, formatter visibility, spawn types, Valkey items, SQL aliases, and the Setextheader variant.

Legacy errors and runtime bindings

Layer / File(s) Summary
Legacy errors and runtime bindings
src/clap/*, src/jsc/*, src/runtime/node/node_process.rs, src/runtime/webcore/*
Removes obsolete CLI errors, JavaScript error sentinels, generated dangerously_set_ptr bindings, native version symbols, obsolete file-reader states, and unsupported stream tags.

Hash and cryptography implementations

Layer / File(s) Summary
Hash and cryptography implementation removal
src/sha_hmac/*, src/wyhash/lib.rs
Removes unused EVP and legacy hashers and removes HashInt implementations for u16 and u64.

Possibly related PRs

  • oven-sh/bun#35880: Removes overlapping obsolete Rust APIs and manifest-cache symbols.
  • oven-sh/bun#36937: Removes dead APIs across several of the same build and runtime files.
  • oven-sh/bun#37062: Removes overlapping symbols in Markdown, SHA, and SQL modules.

Suggested reviewers: jarred-sumner

🚥 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.
Title check ✅ Passed The title clearly summarizes the primary change by identifying the dead-code removal across the main affected areas.
Description check ✅ Passed The description explains the changes and provides detailed verification results, although it does not use the template headings exactly.

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.

@github-actions github-actions Bot added the claude label Aug 7, 2026
@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 10:43 PM PT - Aug 6th, 2026

@robobun, your commit f9fc3ccc64fe5fa98cb6506e19510233cd95ffb1 passed in Build #89877! 🎉


🧪   To try this PR locally:

bunx bun-pr 37089

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

bun-37089 --bun

Comment thread src/install/PackageManifestMap.rs Outdated
Comment thread src/runtime/webcore/FileReader.rs Outdated
Comment thread src/runtime/webcore/Response.rs Outdated
The lint reads the source tree and fails if any deleted symbol
reappears, mirroring the existing dead-symbols tests in
test/internal/source-lints/. Also shortens three comments the
removals had left wordy and applies rustfmt to the touched imports.
Comment thread src/install/PackageManifestMap.rs
Comment thread src/runtime/webcore/FileReader.rs
Comment thread src/runtime/webcore/Response.rs
Comment thread src/bun_core/string/immutable.rs
Comment thread src/jsc/modules/NativeModuleList.h Outdated
Comment thread src/jsc/modules/NativeModuleList.h Outdated
Comment thread src/runtime/server/DevErrorPage.rs Outdated
Comment thread src/runtime/server/DevErrorPage.rs Outdated
Comment thread src/runtime/server/DevErrorPage.rs Outdated
Comment thread src/runtime/server/DevErrorPage.rs Outdated
clippy.toml names rsplit_once_char, split_once, and rsplit_once as the
required replacements for the banned str::split_once family, so they are
lint-policy infrastructure rather than dead code. Keeps the guidance in
clippy.toml pointing at functions that exist.
@robobun
robobun force-pushed the claude/farm/9c2dbd28/dead-code-sweep-misc branch from 59e3338 to f9fc3cc Compare August 7, 2026 04:38

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

Additional findings (outside current diff — PR may have been updated during review):

  • 🔴 src/jsc/modules/NativeModuleList.h:1-27 — Commit 59e3338 ("Restore bun_core::strings split/rsplit helpers") also added four unrelated new files — src/jsc/modules/NativeModuleList.h, src/runtime/server/DevErrorPage.rs, src/runtime/server/dev-error-page.html, and packages/bun-error/schema.ts — none of which are wired up (nothing #includes the header, mod.rs doesn't declare the .rs, nothing imports the .ts) and none of which are mentioned in the PR description. NativeModuleList.h duplicates the BUN_FOREACH_*_NATIVE_MODULE macros already defined in _NativeModule.h:27-46 (REVIEW.md: "Never copy a helper or constant table between modules"), so a dead-code-removal PR is landing ~380 lines of new dead code including a divergence-prone duplicate table. These look like accidentally-staged work from another branch — please drop them from this PR (they belong in whatever feature PR actually wires them up).

    Extended reasoning...

    What the bug is

    Commit 59e3338 is titled "Restore bun_core::strings split/rsplit helpers" and was pushed to address the earlier review comment about clippy.toml referencing deleted helpers. Its commit message discusses only src/bun_core/string/immutable.rs. But git show --stat 59e3338f shows it also added four wholly unrelated new files totalling ~378 lines:

    file lines status
    src/jsc/modules/NativeModuleList.h +39 nothing #includes it; NativeModuleDefaultSlot/m_nativeModuleDefaults unreferenced anywhere
    src/runtime/server/DevErrorPage.rs +207 not declared in src/runtime/server/mod.rs — cargo does not compile it
    src/runtime/server/dev-error-page.html +24 only referenced by the uncompiled .rs above
    packages/bun-error/schema.ts +108 nothing imports it; all bun-error consumers import from ../../src/api/schema

    None of these appear anywhere in the PR description, which otherwise exhaustively itemizes every single deletion down to individual enum variants and HashInt impls.

    Step-by-step verification

    1. NativeModuleList.h is a duplicate constant table. rg 'NativeModuleList\.h|NativeModuleDefaultSlot|m_nativeModuleDefaults' src/ returns only the file itself — nothing includes it, and the enum/constant/"cache array" it defines are unreferenced. Meanwhile src/jsc/modules/_NativeModule.h lines 27-46 already define BUN_FOREACH_ESM_AND_CJS_NATIVE_MODULE / BUN_FOREACH_ESM_NATIVE_MODULE / BUN_FOREACH_CJS_NATIVE_MODULE verbatim. The new header's own comment says it exists "so ZigGlobalObject.h can size its cache array without pulling in _NativeModule.h", but ZigGlobalObject.h doesn't include it and has no m_nativeModuleDefaults field.
    2. DevErrorPage.rs is not compiled. rg 'DevErrorPage|dev_error_page' src/ returns only the file itself and the html template. src/runtime/server/mod.rs does not declare it, so cargo never sees it — which is why bun bd and rust:check-all pass despite it referencing symbols like bun_core::runtime_embed_file!(Codegen, "bun-error/index.js").
    3. dev-error-page.html is only referenced by include_bytes! in the uncompiled .rs.
    4. packages/bun-error/schema.ts is orphaned. rg "from ['\"]\./schema" packages/bun-error/ returns nothing. index.tsx, runtime-error.ts, markdown.ts, and stack-trace-parser.ts all import from "../../src/api/schema" (the pre-existing src/api/schema.js + schema.d.ts), not from the new local file. The new file's header comment even says it is "Produced by src/runtime/server/DevErrorPage.rs" — the same uncompiled file.

    Why this is blocking, not a nit

    REVIEW.md is explicit on both counts:

    • "Never copy a helper or constant table between modules"NativeModuleList.h copies the native-module list out of _NativeModule.h. If someone later adds a native module to _NativeModule.h (the file every existing consumer includes), NativeModuleList.h silently drifts. If both ever get included in one TU, the preprocessor emits macro-redefinition warnings.
    • "Delete dead code in the same PR that makes it dead… Do not stub empty files. Delete dead code." — this PR's stated purpose is dead-code removal, and it exhaustively documents every line it removes. Landing ~380 lines of new unreferenced/uncompiled code is the exact opposite of that purpose.

    The PR's own verification methodology ("verified by rg across src/… then by compiling") did not catch these because (a) an un-#included header and an undeclared .rs module don't participate in compilation, and (b) the PR only grepped for references to removed symbols, not to added ones. The comment-cop bot has already left six unresolved threads on NativeModuleList.h:6,31 and DevErrorPage.rs:3,73,155,196.

    Evidence this is accidental

    The four files form a coherent feature (a Bun.serve({ development: true }) HTML error page: Rust renderer + HTML template + JSON schema + a header refactor to size a per-global cache). They clearly belong to in-progress work on another branch. Commit 59e3338 was a small targeted fix (restore three string helpers + drop 5 lines from the source-lint test); the +378 unrelated lines rode in on the same git add/git commit -a. The PR description — otherwise exhaustive down to "HashInt impls for u16/u64" — mentions none of them.

    How to fix

    Drop the four files from this PR:

    git rm src/jsc/modules/NativeModuleList.h \
           src/runtime/server/DevErrorPage.rs \
           src/runtime/server/dev-error-page.html \
           packages/bun-error/schema.ts
    

    They should land in the feature PR that actually wires DevErrorPage into server/mod.rs, points packages/bun-error at the new schema, and makes _NativeModule.h include (rather than duplicate) the macro list.

@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

The four files flagged above (NativeModuleList.h, DevErrorPage.rs, dev-error-page.html, bun-error/schema.ts) were committed by accident in 59e3338, which that review ran against. The branch was force-pushed as f9fc3cc with the same helper restore and without those files; the PR diff against the base no longer contains them.

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

Thanks for restoring the bun_core::strings split helpers in f9fc3cc — that was my only finding, and the accidental files are gone. I didn't find anything blocking on this revision, but with 38 files across install, jsc/FFI boundaries, webcore, and crypto, it's worth a maintainer glance.

What was reviewed on this pass:

  • StartTag variant removal: confirmed the enum is only used symbolically (const-generic tags / START_TAG consts), never as a wire/ABI u8, so the discriminant shift is inert.
  • js_class_module! dangerously_set_ptr removal: confirmed generate-classes.ts's own Rust output declares its own extern (generate-classes.ts:2473/2498) and none of the ~15 hand-written macro instantiations call it.
  • sha::hashers::{SHA384,SHA512,SHA512_256} removal: confirmed CryptoHasher.rs's hashers:: prefix resolves via use bun_sha_hmac::sha as hashers to the evp re-exports, not the removed submodule.
  • errno::Mode, BUN_DEP_*, Setextheader: no remaining references anywhere.
Extended reasoning...

Overview

Dead-code sweep removing ~250 lines across 38 files: the CacheBehavior enum + parameter from install manifest lookups (all 8 call sites passed the same variant), unused #[no_mangle] statics (Bun__versions_uws/usockets, Zig_ErrorCode*) plus their C++ header declarations, the never-called dangerously_set_ptr wrapper from the js_class_module! macro, never-constructed enum variants (StartTag::{Empty,Err,...}, ReadDuringJSOnPullResult::AmountRead, LineType::Setextheader, clap::Error::WriteFailed), unused deprecated-API hashers in sha_hmac, unused HashInt impls, ~15 unused pub use re-export names, and stale build-script entries. A source-lint test guards against reintroduction.

Security risks

None identified. The crypto-adjacent changes (sha_hmac) remove only unreferenced hasher instantiations; the evp types backing Bun.CryptoHasher and the SHA1/SHA256 deprecated-API hashers used by websocket upgrade and S3 signing all stay. No validation, auth, or TLS logic is touched.

Level of scrutiny

Medium-high. Each removal in isolation is trivial, but the aggregate touches:

  • FFI/ABI boundaries (#[no_mangle] statics, extern "C" declarations in headers-handwritten.h) — mitigated by full bun bd link succeeding, which is decisive for link-time symbols.
  • A macro (js_class_module!) that fans out into every hand-written JS class module.
  • The package manager's manifest-cache hot path (by_name_hash_allow_expired).
  • #[repr(u8)] enum variant removal that shifts discriminants.

The verification story is strong: cargo check, full build+link, rust:check-all across all 10 targets, and targeted smoke tests (bun-cryptohasher, arraybuffersink, minimum-release-age, update-interactive) all pass. The PR description exhaustively itemizes every deletion with its zero-reference proof.

Other factors

  • My prior review flagged an unintentional deletion of bun_core::strings::{rsplit_once_char,split_once,rsplit_once} (referenced by clippy.toml as the mandated SIMD replacements for banned std methods). The author restored them in f9fc3cc and dropped the accidental NativeModuleList.h/DevErrorPage.rs files. The current diff no longer touches immutable.rs.
  • I spot-checked the four removals I judged riskiest on this revision (StartTag discriminants, dangerously_set_ptr vs generate-classes.ts's separate surface, CryptoHasher's hashers:: alias resolution, errno::Mode) — all check out exactly as the PR description claims.
  • The CacheBehavior::LoadFromMemory branch removal is behavior-preserving because that variant was never constructed; by_name_hash_in_memory (the actual memory-only path) stays.
  • The comment-cop bot's remaining flags were argued as documenting invariants rather than justifying workarounds; those threads are resolved.

Deferring rather than approving because 38 files across install/jsc/webcore/sha_hmac plus C++ header edits is broad enough that a maintainer should skim the deletion list, even though I found nothing wrong.

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