Repository navigation
Remove dead code from libuv_sys, cares_sys, simdutf FFI, test_runner, and C++ bindings - #37332
Conversation
… and C++ bindings
Rust:
- bun_libuv_sys (Windows-only): 169 extern declarations no Rust code
referenced (tcp/udp/tty/poll/prepare/check/fs_poll/threading/os-info
surface), the structs and callback aliases only they used, the UvReq
marker trait, Loop/Pipe/async helper methods nobody called, and the
StdioFlags / UV_FS_O_* / priority / clock alias tables. bun_spawn now
uses UV_INHERIT_FD directly like the rest of that file.
- bun_cares_sys: ares_init/ares_send/ares_search/ares_gethostbyname/
ares_getsock/ares_timeout/ares_create_query/ares_expand_*/
ares_parse_uri_reply/ares_free_string/ares_library_init/ares_version
declarations, ares_socket_functions, struct_ares_uri_reply, and the
Windows timeval/iovec definitions that existed only for them.
- bun_brotli_sys: BrotliDecoder::{is_finished,get_error_code,version}
and the BrotliDecoderIsFinished/BrotliDecoderVersion declarations.
- bun_simdutf_sys: 22 unused extern declarations plus the 30 C++
wrappers in bun-simdutf.cpp that no longer had a caller or a
declaration (and their stubs in the parser bench shim).
- test_runner: JSValueTestExt forwarders that bun_jsc inherent methods
of the same name shadow, so no call could resolve to them; never-read
global_this fields on two formatter structs; FetchOptions.global_this;
S3ErrorJsc::to_js.
C++:
- Events_function{GetEventListeners,ListenerCount,Once,On} host
functions and the jsEventEmitterCast/JSEventEmitterWrapper helpers
only they used; jsFunctionDebugNoop and jsFunctionSyncBuiltinExports in
NodeModuleModule.cpp; jsCookieStaticFunctionSerialize and the
Cookie::serialize(span) overload behind it; nine getter declarations in
JSBakeResponse.cpp with no definition.
- UTF8Encoding(), createMockResultStructure, ActiveDOMObject::
queueTaskToDispatchEvent (+ queueTaskToDispatchEventInternal,
isAllowedToRunScript, PendingActivity::object), StreamQueue::
setTotalSize, WorkerMessagingProxy getters, unused DOMIsoSubspaces /
DOMClientIsoSubspaces slots, the commonStringInitializer typedef and
the BUN_FOREACH_CJS_NATIVE_MODULE macro.
- The five cross-realm transform stubs (declared in WebStreamsInternals.h,
each only threw "not implemented") and CrossRealmMessageType.
- EventInterfaces.h / EventTargetInterfaces.h trimmed to the interfaces
bun actually reports; surviving enumerators keep their values.
Verified with rg across src/, scripts/, test/ and regenerated codegen
output, cargo check --workspace on all 10 CI targets, cargo check
--workspace --tests, and a full bun bd build. The new source lint pins
the removed symbols.
WalkthroughThe pull request removes unused FFI declarations, WebCore and JSC binding APIs, runtime fields, SIMDUTF wrappers, and Web Streams transfer stubs. It updates Windows process spawning and adds source-lint checks for removed symbols. ChangesExternal-library FFI reduction
Windows libuv surface and spawn wiring
WebCore and JSC binding cleanup
Web Streams API reduction
Runtime and SIMDUTF cleanup
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Status (head 3f65303): ready for a maintainer.
|
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. Given the breadth (43 files, ~1700 lines across libuv_sys/cares_sys/simdutf/test_runner/C++ bindings) and the one deletion the description flags as a judgment call (the CrossRealmTransform "frozen placeholder" stubs in WebStreamsInternals.h), a human look would still be worthwhile before this lands.
What was reviewed:
- Spot-checked that removed
JSValueTestExtforwarders (to_fmt,jest_deep_equals, …) are shadowed bybun_jsc::JSValueinherents;toHaveReturnedWith.rsstill resolves. - Confirmed
SuccessfulReturnsFormatter's'glifetime is still bound viaFormatter<'g>after the field removal, andFetchOptions::global_thisis distinct from theFetchTasklet::global_thisthat is actually read. - Verified none of the removed
m_subspaceFor*/m_clientSubspaceFor*slots orjsEventEmitterCast(non-Fast) are referenced anywhere insrc/. - Checked the new source-lint's simdutf Rust↔C++ symbol-set assertion covers the
mod base64declarations and that its\bjsEventEmitterCast\bregex won't false-positive onjsEventEmitterCastFast.
Extended reasoning...
Overview
This is a scheduled dead-code sweep removing ~1700 lines across 43 files: unused extern "C" declarations and structs in the Windows-only bun_libuv_sys crate (~619 lines), bun_cares_sys, bun_brotli_sys, both sides of the simdutf FFI, unused JSValueTestExt trait forwarders in the test runner, never-read struct fields (CustomMatcherParamsFormatter::global_this, SuccessfulReturnsFormatter::global_this, FetchOptions::global_this), and a large set of C++ bindings (uninstalled Events_function* host functions, jsCookieStaticFunctionSerialize, ActiveDOMObject::queueTaskToDispatchEvent, unused iso-subspace slots, the CrossRealmTransform stubs, and trimming the WebCore EventInterfaces/EventTargetInterfaces enums to the entries Bun actually reports). A new source-lint test pins 67 of the removed symbols and asserts the simdutf Rust and C++ declaration sets stay in sync.
Security risks
None. This is pure deletion of unreferenced declarations, wrappers, and struct fields; no data flow, validation, or auth path changes. The only added code is a source-tree lint that reads files with readFileSync and matches regexes.
Level of scrutiny
Moderate-to-high. Each individual deletion is mechanical and the PR description documents an unusually thorough verification (rg across src/scripts/test/packages + regenerated codegen output, cargo check on all 10 CI triples including the Windows-only libuv crate, full bun bd, targeted test runs). I spot-checked several load-bearing claims and they held: to_fmt is a JSValue inherent so the trait forwarder was truly shadowed; the 'g lifetime on SuccessfulReturnsFormatter is still bound after the field removal; the removed FetchOptions::global_this is a different field from the heavily-used FetchTasklet::global_this; none of the removed iso-subspace slots or jsEventEmitterCast appear anywhere in src/; c_ushort is still used in c_ares.rs after c_long was dropped from the import.
However, the sheer breadth (Windows-only FFI that only Windows CI exercises, WebCore-ported enums, streams internals) and the fact that one deletion is explicitly flagged by the author as a judgment call rather than a provable leftover put this outside the "simple/mechanical" bar for auto-approval.
Other factors
- The author explicitly calls out the CrossRealmTransform stub deletion as "the one group in the PR that is a judgment call rather than a leftover, so it is easy to drop if you would rather keep the placeholders" — that's a maintainer decision, not something an automated review should sign off on.
- The description notes a known merge interaction with #32268 (which adds
RETURN_IF_EXCEPTIONinside theEvents_function*bodies deleted here). - CI is described as "waiting"; the Windows lanes are the only place the ~619-line
bun_libuv_sysdeletion is compile-checked. - No prior human review on the timeline; CodeRabbit was rate-limited.
|
Thanks for the pass. On the two points worth tracking for a human reviewer:
|
|
Updated 7:20 PM PT - Aug 10th, 2026
✅ @robobun, your commit 3f65303a0ed52e176edc5107d6273d0d7bf44c14 passed in 🧪 To try this PR locally: bunx bun-pr 37332That installs a local version of the PR into your bun-37332 --bun |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/simdutf_sys/simdutf.rs (1)
36-40: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winProtect the complete deleted SIMDUTF surface.
The source-lint deny-list in
test/internal/source-lints/dead-symbols-ffi-sys-test-runner-cpp.test.tsdoes not include every symbol removed here. For example, it omitssimdutf__convert_valid_utf8_to_utf16beandsimdutf__convert_utf8_to_utf32.If Rust and C++ reintroduce both declarations, the parity assertion passes and the lint does not detect the regression. Add every removed symbol to the deny-list, or generate the list from one manifest.
The shown source-lint expression and the removed declarations provide the supporting evidence.
Also applies to: 61-61, 71-71, 91-91, 101-101, 111-111, 121-121, 129-130
🤖 Prompt for 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. In `@src/simdutf_sys/simdutf.rs` around lines 36 - 40, Expand the deny-list in dead-symbols-ffi-sys-test-runner-cpp.test.ts to include every removed SIMDUTF FFI symbol, including simdutf__convert_valid_utf8_to_utf16be and simdutf__convert_utf8_to_utf32, so reintroduced Rust and C++ declarations are detected. Prefer deriving the list from a shared manifest if the existing test structure supports it, and preserve the parity assertion.
🤖 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 `@test/internal/source-lints/dead-symbols-ffi-sys-test-runner-cpp.test.ts`:
- Line 78: Update the dead-symbols test entry to match the actual `struct
ares_uri_reply` declaration, replacing the underscore-form pattern with a
pattern that accounts for the whitespace between `struct` and `ares_uri_reply`.
- Line 139: Update the dead-symbol test entry for
jsCookieStaticFunctionSerialize to reference src/jsc/bindings/Cookie.cpp instead
of JSCookie.cpp, ensuring the check reads the file containing the removed
declaration.
---
Outside diff comments:
In `@src/simdutf_sys/simdutf.rs`:
- Around line 36-40: Expand the deny-list in
dead-symbols-ffi-sys-test-runner-cpp.test.ts to include every removed SIMDUTF
FFI symbol, including simdutf__convert_valid_utf8_to_utf16be and
simdutf__convert_utf8_to_utf32, so reintroduced Rust and C++ declarations are
detected. Prefer deriving the list from a shared manifest if the existing test
structure supports it, and preserve the parity assertion.
🪄 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: 319eecd7-6ff3-4bf2-8257-cac7796f545f
📒 Files selected for processing (43)
src/brotli_sys/brotli_c.rssrc/cares_sys/c_ares.rssrc/cares_sys/lib.rssrc/jsc/bindings/BunHttp2CommonStrings.hsrc/jsc/bindings/Cookie.cppsrc/jsc/bindings/Cookie.hsrc/jsc/bindings/DOMFormData.hsrc/jsc/bindings/JSBakeResponse.cppsrc/jsc/bindings/JSMockFunction.cppsrc/jsc/bindings/TextEncoding.cppsrc/jsc/bindings/TextEncoding.hsrc/jsc/bindings/webcore/ActiveDOMObject.cppsrc/jsc/bindings/webcore/ActiveDOMObject.hsrc/jsc/bindings/webcore/DOMClientIsoSubspaces.hsrc/jsc/bindings/webcore/DOMIsoSubspaces.hsrc/jsc/bindings/webcore/EventInterfaces.hsrc/jsc/bindings/webcore/EventTargetInterfaces.hsrc/jsc/bindings/webcore/JSCookie.cppsrc/jsc/bindings/webcore/JSEventEmitter.cppsrc/jsc/bindings/webcore/JSEventEmitter.hsrc/jsc/bindings/webcore/JSEventEmitterCustom.cppsrc/jsc/bindings/webcore/JSEventEmitterCustom.hsrc/jsc/bindings/webcore/Performance.hsrc/jsc/bindings/webcore/WorkerMessagingProxy.hsrc/jsc/bindings/webcore/streams/CrossRealmTransform.cppsrc/jsc/bindings/webcore/streams/JSWritableStreamDefaultController.cppsrc/jsc/bindings/webcore/streams/StreamQueue.hsrc/jsc/bindings/webcore/streams/StreamsForward.hsrc/jsc/bindings/webcore/streams/WebStreamsInternals.hsrc/jsc/modules/NativeModuleList.hsrc/jsc/modules/NodeModuleModule.cppsrc/libuv_sys/libuv.rssrc/parsers/benches/support/simdutf_shim.cppsrc/runtime/test_runner/expect.rssrc/runtime/test_runner/expect/toHaveReturnedWith.rssrc/runtime/test_runner/mod.rssrc/runtime/webcore/fetch.rssrc/runtime/webcore/fetch/FetchTasklet.rssrc/runtime/webcore/s3/error_jsc.rssrc/simdutf_sys/bun-simdutf.cppsrc/simdutf_sys/simdutf.rssrc/spawn/process.rstest/internal/source-lints/dead-symbols-ffi-sys-test-runner-cpp.test.ts
💤 Files with no reviewable changes (33)
- src/jsc/bindings/TextEncoding.h
- src/jsc/bindings/webcore/streams/StreamQueue.h
- src/jsc/bindings/Cookie.cpp
- src/jsc/bindings/DOMFormData.h
- src/jsc/modules/NativeModuleList.h
- src/jsc/bindings/JSBakeResponse.cpp
- src/jsc/bindings/webcore/JSEventEmitterCustom.cpp
- src/jsc/bindings/webcore/streams/StreamsForward.h
- src/jsc/bindings/JSMockFunction.cpp
- src/runtime/test_runner/expect/toHaveReturnedWith.rs
- src/jsc/bindings/TextEncoding.cpp
- src/jsc/bindings/webcore/WorkerMessagingProxy.h
- src/jsc/bindings/webcore/JSEventEmitterCustom.h
- src/runtime/webcore/fetch.rs
- src/jsc/bindings/webcore/JSCookie.cpp
- src/parsers/benches/support/simdutf_shim.cpp
- src/jsc/bindings/Cookie.h
- src/runtime/webcore/s3/error_jsc.rs
- src/jsc/bindings/webcore/Performance.h
- src/jsc/bindings/webcore/ActiveDOMObject.cpp
- src/jsc/bindings/webcore/streams/WebStreamsInternals.h
- src/jsc/bindings/BunHttp2CommonStrings.h
- src/jsc/bindings/webcore/ActiveDOMObject.h
- src/jsc/bindings/webcore/JSEventEmitter.cpp
- src/jsc/bindings/webcore/EventTargetInterfaces.h
- src/jsc/bindings/webcore/EventInterfaces.h
- src/jsc/modules/NodeModuleModule.cpp
- src/simdutf_sys/bun-simdutf.cpp
- src/jsc/bindings/webcore/DOMIsoSubspaces.h
- src/brotli_sys/brotli_c.rs
- src/runtime/test_runner/mod.rs
- src/jsc/bindings/webcore/DOMClientIsoSubspaces.h
- src/jsc/bindings/webcore/JSEventEmitter.h
The parity assertion alone would pass if a removed wrapper came back on both sides of the FFI at once, so list all 30 removed names instead of a sample.
|
Review sweep after the CodeRabbit pass:
No open threads; waiting on CI for the new head. |
- simdutf bench shim: drop the three latin1 wrappers that never had a Rust declaration, and make the lint assert the shim only defines symbols simdutf.rs declares. - libuv.rs: remove the now-empty "errors" and "udp" section headers and fold the three declarations left under "ip" into the misc group. - ActiveDOMObject.cpp: drop the Event.h/EventTarget.h includes that only the removed queueTaskToDispatchEventInternal used.
|
Pushed 8db13c3 for the three review nits: the bench shim's three latin1 wrappers with no Rust declaration are removed (and the lint now checks the shim only defines symbols |
… uv_lib_t and uv_dir_t The size assertion for WIN32_FIND_DATAW only guarded its embedding in uv_dir_t; the canonical one lives next to the type in bun_windows_sys.
|
Pushed 3f65303 for the last review nit: |
There was a problem hiding this comment.
I reviewed this PR again after 3f65303 and the bug-hunting pass found no issues; all four earlier nits (simdutf shim orphans, libuv section headers, ActiveDOMObject includes, HMODULE/WIN32_FIND_DATAW re-exports) are addressed and every thread is resolved. Given the breadth of the sweep across FFI crates and C++ bindings, the author-flagged judgment call on removing the CrossRealmTransform placeholder stubs, and the noted rebase interaction with #32268, a human sign-off is still worthwhile.
What was reviewed
- Spot-checked removed FFI symbols (
uv_*,ares_*,simdutf__*) againstsrc/and codegen for callers; the simdutf Rust↔C++ parity assertion in the new lint holds. - Confirmed
EventInterfaces.h/EventTargetInterfaces.hsurvivors keep their numeric values and both factories havedefault:arms. - Verified
jsCookieStaticFunctionSerialize/Events_function*were never installed on any HashTableValue andjsFunctionSyncBuiltinExportsis distinct from the livejsFunctionSyncBuiltinESMExports. - Checked the
StdioFlags→UV_INHERIT_FDrewrite insrc/spawn/process.rsis value-preserving and covers all three call sites.
Extended reasoning...
Overview
Scheduled dead-code sweep removing ~1750 lines across 43 files: unused libuv/c-ares/brotli/simdutf FFI declarations (Rust extern blocks plus their C++ wrapper counterparts), shadowed JSValueTestExt forwarder methods and never-read struct fields in bun_runtime, and a batch of C++ bindings that were declared/defined but never installed (JSEventEmitter Events_function*, jsCookieStaticFunctionSerialize, jsFunctionDebugNoop/SyncBuiltinExports, createMockResultStructure, UTF8Encoding, ActiveDOMObject event-dispatch helpers, unused iso-subspace slots, the CrossRealmTransform throw-only stubs, and trimming the WebCore EventInterfaces/EventTargetInterfaces enums to the entries bun actually reports). One functional edit outside pure deletion: three StdioFlags::INHERIT_FD uses in src/spawn/process.rs become UV_INHERIT_FD (same value). A new source-lint test pins ~67 removed symbols and asserts simdutf Rust/C++/shim parity.
Security risks
None identified. Everything removed was uncallable (no Rust caller, not installed on any prototype/constructor, or throw-only stubs with no reachable path). No auth, crypto, permission, or input-validation surfaces are touched. The only value-bearing change (StdioFlags::INHERIT_FD → UV_INHERIT_FD) is a rename between two constants both defined as 4.
Level of scrutiny
High, and it has received it: the PR went through two CodeRabbit findings (both withdrawn as incorrect), three earlier inline nits from this reviewer plus one follow-up (all fixed in 8db13c3 / 3f65303), and the author documented per-symbol rg verification across src/, scripts/, test/, packages/, and regenerated build/debug/codegen/, with cargo check --workspace on all 10 CI triples and a full bun bd. That said, this is a wide sweep across C++ JSC bindings and Windows-only FFI, and the author explicitly flagged the CrossRealmTransform stub removal as a judgment call ("easy to drop if you would rather keep the placeholders") — that is a maintainer decision, not something an automated review should make.
Other factors
The PR notes a rebase interaction with #32268 (whichever lands second drops the Events_function* hunks). The EventInterfaces enum trimming preserves numeric values for survivors and both factories have default: arms, so I did not find a hazard there, but it and the streams-placeholder removal are the two spots where a maintainer's confirmation is most useful. Deferring rather than approving on those grounds; no code changes are requested.
…c_sys, and orphaned files (#38213) Scheduled dead-code sweep. Areas were chosen to avoid the 17 dead-code PRs currently open (#35437 through #38005): every file below was either untouched by those PRs or, where a file is shared, the hunks are different symbols (checked mechanically against the open PR diffs; the only shared removed lines are `level = "expect"` style TOML boilerplate in unrelated `hawk.toml` blocks). Net: 47 files, about 2.7k lines removed; the only additions are the guard test, three one-line `#[cfg]` / import adjustments, and two doc-comment fixes for functions that went away. ### Removed **WebCore streams bindings (transferable streams were never implemented)** - `m_detached` bitfields on `JSReadableStream`, `JSWritableStream`, `JSTransformStream`: never read or written. - `$bunNativeType` / `$disturbed` private-name accessors on `ReadableStream.prototype` (4 getters/setters, their installs, `m_nativeType`, the reset in `ReadableStream__detach`, the two `BunBuiltinNames.h` entries and `builtins.d.ts` declarations): no builtin, C++ or test referenced either name. `$bunNativePtr` is still used and stays. **TextEncoder** - `TextEncoder::encode` / `encodeInto` / `EncodeIntoResult` and the `convertDictionary<EncodeIntoResult>` / `convertDictionaryToJS` specializations (`TextEncoder.h`, `TextEncoder.cpp`, `JSTextEncoder.h`, `JSTextEncoder.cpp`): the wrapper implements both methods through the Rust `TextEncoder__encode*` exports and only ever calls `impl.encoding()`, which is all that is left of the impl class. **node:crypto** - `JSKeyObject::create` and `JSKeyObject::subspaceFor` plus the `m_subspaceForJSKeyObject` / `m_clientSubspaceForJSKeyObject` slots: every key object is one of the three final subclasses, each of which defines its own `create`/`subspaceFor`; the base class is only used as a downcast target. - Commented-out `switch (m_curve)` block in `CryptoKeyOKP::algorithm()` (2023). **Other bindings** - `WriteBarrierList::list()`, the `WeakRefFinalizeFn` typedef in `Weak.cpp`, `JSC_MAC_VERSION_TBA` / `JSC_IOS_VERSION_TBA` in `root.h` (unused by every JSC header in the WebKit builds we ship against). - `Bun__resolve` host export (`bun_resolve` in `BunObject.rs` + the `extern "C"` declaration in `ImportMetaObject.h`): nothing in C++ or JS called it; the `Bun__resolveSync*` family is what is used. **node:http (`src/js/node/_http_server.ts`)** - `kDeprecatedReplySymbol` is a module-private `Symbol()` in `internal/http` that nothing ever sets on a response's options, so the constructor branch that installed the fetch-`Response` based `write`/`end` was unreachable. Removed it together with everything only it reached: `ServerResponse_writeDeprecated`, `ServerResponse_finalDeprecated`, `ensureReadableStreamController`, `drainHeadersIfObservable`, `emitRequestCloseNT`, `GlobalPromise`, and the now-unused imports (`controllerSymbol`, `firstWriteSymbol`, `deferredSymbol`, `runSymbol`, `emitErrorNextTickIfErrorListenerNT`). This also stops adding an `undefined`-valued `Symbol(deprecatedReply)` own property to every `ServerResponse`. - The `isNextIncomingMessageHTTPS` save/set/restore around request dispatch: the flag's only reader was removed in c4a937c, so the calls had no effect. - A 2025 commented-out `cluster._getServer` block in `Server.prototype.listen`. **Rust** (cross-crate analysis with hawk per `tools/hawk/README.md`, then each item re-checked with `rg`; callers were confirmed to be platform-gated, e.g. `node_fs` uses `sys_uv` on Windows) - `bun_sys`: `link`, `fdatasync` and the non-Linux `sendfile` stub (both the posix and Windows arms), the Windows arms of `fchown`, `chmod`, `chown`, `fsync`, `linkat`, `fchmodat`, `lchmod`, `lchown`, `futimens`, `lutimens`, `fcntl`, `socketpair`, the Windows `Name::as_zstr`, `c::kqueue` / `c::kevent` / `c::fork` / `c::fd_t`, `linux::Errno`, `darwin::OSLog::as_ptr`, the non-macOS `clonefile` stub, the non-Windows `get_fd_path_w` stub, `posix::sysctlbyname` (the typed `sysctl_read*` helpers stay), `posix::write`; and the two helpers that became unreferenced as a result, `linux_syscall::write_raw` and the `safe_libc::fdatasync` import, plus `windows::timespec_to_filetime`. `Tag::futimens` is now `#[cfg(not(windows))]` like the other tags whose only users are posix-side (the Windows `cargo check` flagged it once its Windows user was gone). - `bun_lsquic_sys`: the `Engine` wrapper (struct, impl, `Drop`), `Conn::{raw, set_ctx, ctx, n_avail_streams, sockaddr, status}`, `global_init`, `enable_logging`, `LSQVER_I001/I002`, and the `lsquic_conn_n_avail_streams` extern. `node:quic` drives lsquic through the raw externs directly. - `bun_spawn_sys`: `PosixSpawnResult::close` and the non-Linux `pifd_from_pid` stub (the only call site is Linux-gated). The `FdExt` import that `close` was the last Windows user of is now `#[cfg(unix)]`. - `bun_tcc_sys`: `State::run` and the `tcc_run` extern. - `hawk.toml`: the six `bun_platform` `darwin::Category::*` overrides, whose variants were deleted in #36833 (hawk reports them as `unknown_item`). **Orphaned files** (zero references repo-wide, searched with `git grep` including `.github`, `.buildkite`, `.vscode`, `scripts/`, `packages/` and the generated `build/debug/codegen/`) - `misctools/gdb/std_gdb_pretty_printers.py` (Zig standard-library pretty printers; the repo has no Zig left) and the `.vscode/launch.json` line that sourced it; `misctools/mime.js` (emitted a Zig `ComptimeStringMap`; MIME types now come from `src/http_types/mime_type_list.txt`); `misctools/.gitignore` (ignored outputs of Zig programs deleted long ago). - `patches/ncrypto.patch`: a one-off diff against Node's ncrypto committed with #17692. Unlike every other file under `patches/`, no `scripts/build/deps/*.ts` applies it, and `ncrypto.cpp`/`.h` have changed many times since, so it no longer describes anything. - `meta.json` (stray `--metafile` output committed in #26441), `workspace.code-workspace` (2021 single-folder VS Code workspace with Zig settings; `.vscode/` is the live config). - `src/jsc/bindings/v8-capture-stack-fixture.cjs`, `src/jsc/bindings/webcore/EventNames.in` (WebKit `make_event_factory.pl` input; Bun's `EventNames.h` is hand-written), `src/runtime/ffi/libtcc1.a.macos-aarch64` (superseded by the embedded `libtcc1.c`). - `src/runtime/bake/client/JavaScriptSyntaxHighlighterComponent.tsx` (its header says the client never uses it) and `JavaScriptSyntaxHighlighter.css`, which only it imported. The live `JavaScriptSyntaxHighlighter.ts` is untouched. - `packages/bun-release/scripts/npm-exec.ts` (`upload-npm.ts` bundles only `npm-postinstall.ts` and ships placeholder bins), `packages/bun-usockets/misc/{manual.md,gen_test_certs.sh,layout.png}` and `packages/bun-usockets/module.modulemap` (upstream leftovers, same class as the `bun-uws/misc` files removed in #37659). ### Verification - `rg` / `git grep` for every symbol and file name above across `src/`, `scripts/`, `packages/`, `test/`, `vendor/WebKit/Source` (for the C++ symbols) and freshly regenerated `build/debug/codegen/`. - Rust items come from a hawk `dead_public` report on this tree (release profile, all 11 shipped targets), filtered to items no open PR deletes; findings that are FFI struct fields, code tables, or API added in the last week were deliberately left alone. - `bun bd` builds, and the removed symbols are absent from the resulting binary / bundled JS / `generated_host_exports.rs`. `bun bd test` passes on `test/js/web/streams/streams.test.js`, `test/js/web/encoding/text-encoder.test.js`, `test/js/node/crypto/crypto.key-objects.test.ts`, `test/js/node/fs/fs.test.ts`, `test/js/bun/resolve/import-meta*.test.*` and `test/js/node/quic/quic-stream.test.ts`; `test/js/node/http/node-http.test.ts` passes except "request via http proxy, issue#4295", which fails identically with an unmodified bun in this container (ECONNREFUSED to its local proxy). - `cargo check --workspace` on the windows-msvc, darwin, freebsd, linux-musl, android and linux-gnu targets. - `test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts` pins everything above; all 40 content checks and 16 deleted-file checks fail against main and pass here. ### Left alone (probably dead, not deleted) - `src/simdutf_sys/simdutf.rs`: the whole `utf32` / big-endian wrapper tree (~150 lines, plus its externs and the matching shims in `bun-simdutf.cpp`) has no callers, but #37332 is editing the same extern block; worth a follow-up once that lands. Same story for the unused `Loop` / `uv_stat_t` / `ReturnCode` helpers in `libuv_sys`. - `src/js/internal/http.ts`: `kDeprecatedReplySymbol`, `controllerSymbol`, `runSymbol`, `deferredSymbol`, `firstWriteSymbol` and `get/setIsNextIncomingMessageHTTPS` lost their last users in this PR, but #35437 rewrites that exact region of the file. - The rest of the transferable-streams scaffolding: `JSCrossRealmTransformState` (never created; its only references are its `FOR_EACH_WEB_STREAMS_INTERNAL_STRUCTURE` entry and iso-subspace slots), `CrossRealmTransform.cpp`, and the `SourceKind::CrossRealm` / `SinkKind::CrossRealm` arms with their `case` labels. #37332 is already editing that cluster, so it is best removed as one unit once that lands. - `misctools/gen-unicode-table.ts` + `unicode-generator.ts` emit Zig source, but `src/bun_core/string/identifier.rs` still points at them as the generator to port; `misctools/generate-cli-completions.ts` + `completions/bun-cli.json` and `completions/spec.yaml` have no in-repo consumers but may have external ones. - `src/runtime/bake/{incremental,memory}_visualizer.html` (~800 lines): nothing serves them since the port, but `DevServer` still carries the message writers and stubs, so this looks like an unfinished port rather than dead code. - `packages/bun-inspector-frontend` (build script points at a path that no longer exists) and `packages/bun-build-mdx-rs` (2024 proof of concept) are unreferenced but are a product call. - `bun_shim_impl::read_without_launch` is the Windows `bunx` fast path that nothing calls any more; deleting it would drop a feature rather than a leftover. <!-- robobun:evidence:begin --> --- **[review]** gate passed · iteration 1 · 47 files touched <details><summary>fails on main (without fix)</summary> ```console 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-streams-http-misctools.test.ts bun test v1.4.0 (59bf369) test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts: 71 | // The Bun__resolve host export had no C++ or JS caller (only Bun__resolveSync 72 | // and its variants are used). 73 | ["src/jsc/bindings/ImportMetaObject.h", /\bBun__resolve\(/], 74 | ["src/runtime/api/BunObject.rs", /HOST_EXPORT\(Bun__resolve,|\bfn bun_resolve\b/], 75 | ]), 76 | ).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "src/jsc/bindings/webcore/streams/JSReadableStream.h: \bm_detached\b|\bm_nativeType\b", + "src/jsc/bindings/webcore/streams/JSTransformStream.h: \bm_detached\b", + "src/jsc/bindings/webcore/streams/JSWritableStream.h: \bm_detached\b", + "src/jsc/bindings/webcore/streams/JSReadableStream.cpp: bunNativeTypePrivateName|disturbedPrivateName", + "src/js/builtins/BunBuiltinNames.h: macro\((bunNativeType|disturbed)\)", + "src/jsc/bindings/webcore/TextEncoder.h: EncodeInto ... (truncated) release without fix: 3 FAILED bun test v1.4.0-canary.1 (da3851e) test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts: 71 | // The Bun__resolve host export had no C++ or JS caller (only Bun__resolveSync 72 | // and its variants are used). 73 | ["src/jsc/bindings/ImportMetaObject.h", /\bBun__resolve\(/], 74 | ["src/runtime/api/BunObject.rs", /HOST_EXPORT\(Bun__resolve,|\bfn bun_resolve\b/], 75 | ]), 76 | ).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "src/jsc/bindings/webcore/streams/JSReadableStream.h: \bm_detached\b|\bm_nativeType\b", + "src/jsc/bindings/webcore/streams/JSTransformStream.h: \bm_detached\b", + "src/jsc/bindings/webcore/streams/JSWritableStream.h: \bm_detached\b", + "src/jsc/bindings/webcore/streams/JSReadableStream.cpp: bunNativeTypePrivateName|disturbedPrivateName", + "src/js/builtins/BunBuiltinNames.h: macro\((bunNativeType|disturbed)\)", + "src/jsc/bindings/webcore/TextEncoder.h: EncodeIntoResult|\bencodeInto\b", + "src/jsc/bindings/webcore/TextEncoder.cpp: TextEncoder::encode(Into)?\(", + "src/jsc/bindings/webcore/JSTextEncoder.h: EncodeIntoResult", + "src/jsc/bindings/webco ... (truncated) ``` </details> <details><summary>passes on PR (with fix)</summary> ```console 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-streams-http-misctools.test.ts bun test v1.4.0 (59bf369) test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts: (pass) dead stream slots and other dead C++ bindings do not reappear [33.31ms] (pass) the deprecated-reply ServerResponse path stays out of node:http [21.74ms] (pass) dead Rust wrappers do not reappear [63.04ms] (pass) orphaned files stay deleted [545.87ms] 4 pass 0 fail 4 expect() calls Ran 4 tests across 1 file. [3.00s] __F:0:S:0 release with fix: all passed $ bun scripts/build.ts --profile=release [configured] bun-profile → bun (stripped) in 662ms (unchanged) ninja: Entering directory `/workspace/bun/build/release' [1/130] gen bake.{client,server,error}.js -> bake.client.js, bake.server.js, bake.error.js [2/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 [3/130] gen cpp.rs (cppbind) [4/130] gen JS modules (bundle-modules) Preprocess modules (9626ms) Bundle modules (50ms) Postprocesss modules (239ms) Bundle Functions (777ms) Generate Code (34ms) [10.75s] Bundled "src/js" for production 2622 kb 197 internal modules 13 native modules 91 internal functions across 17 files [4/129] 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 ... (truncated) ``` </details> <details><summary>diff hotspot</summary> ``` .vscode/launch.json | 1 - hawk.toml | 48 -- meta.json | 24 - misctools/.gitignore | 10 - misctools/gdb/std_gdb_pretty_printers.py | 142 ---- misctools/mime.js | 46 -- packages/bun-release/scripts/npm-exec.ts | 13 - packages/bun-usockets/misc/gen_test_certs.sh | 51 -- packages/bun-usockets/misc/layout.png | Bin 10991 -> 0 bytes packages/bun-usockets/misc/manual.md | 180 ---- packages/bun-usockets/module.modulemap | 4 - patches/ncrypto.patch | 919 --------------------- src/js/builtins.d.ts | 2 - src/js/builtins/BunBuiltinNames.h | 2 - src/js/node/_http_server.ts | 209 ----- src/jsc/bindings/ImportMetaObject.h | 1 - src/jsc/bindings/Weak.cpp | 2 - src/jsc/bindings/WriteBarrierList.h | 5 - src/jsc/bindings/node/crypto/JSKeyObject.h | 20 - src/jsc/bindings/root.h | 3 - src/jsc/bindings/v8-capture-stack-fixture.cjs | 15 - src/jsc/bindings/webcore/DOMClientIsoSubspaces.h | 1 - src/jsc/bindings/webcore/DOMIsoSubspaces.h | 1 - src/jsc/bindings/webcore/EventNames.in | 101 --- src/jsc/bindings/webcore/JSTextEncoder.cpp | 56 -- src/jsc/bindings/webcore/JSTextEncoder.h | 4 - src/jsc/bindings/webcore/TextEncoder.cpp | 36 - src/jsc/bindings/webcore/TextEncoder.h | 9 - .../bindings/webcore/streams/JSReadableStream.cpp | 60 +- .../bindings/webcore/streams/JSReadableStream.h | 4 - .../bindings/webcore/streams/JSTransformStream.h | 2 - .../bindings/webcore/streams/JSWritableStream.h | 2 - .../bindings ... (truncated) ``` </details> **gate history** · 1 passed · 1 rejected · iteration 1 <details><summary>evidence per changed file</summary> ``` file reads edits tests .vscode/launch.json 0 0 0 hawk.toml 0 0 0 meta.json 0 0 0 misctools/.gitignore 0 0 0 misctools/gdb/std_gdb_pretty_printers.py 0 0 0 misctools/mime.js 0 0 0 packages/bun-release/scripts/npm-exec.ts 0 0 0 packages/bun-usockets/misc/gen_test_certs.sh 0 0 0 packages/bun-usockets/misc/layout.png 0 0 0 packages/bun-usockets/misc/manual.md 0 0 0 packages/bun-usockets/module.modulemap 0 0 0 patches/ncrypto.patch 0 0 0 src/js/builtins.d.ts 0 0 0 src/js/builtins/BunBuiltinNames.h 0 0 0 src/js/node/_http_server.ts 5 0 0 src/jsc/bindings/ImportMetaObject.h 0 0 0 (+ 31 more files) ``` </details> <!-- robobun:evidence:end --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Scheduled dead-code sweep. Areas this run:
src/libuv_sys,src/cares_sys,src/brotli_sys,src/simdutf_sys(both sides of the FFI),src/runtime/test_runner, a fewbun_runtimeleftovers, and C++ bindings outside the files the other open dead-code PRs touch. Net: 43 files, +218 (the new lint) / -1723.Removed
bun_libuv_sys(Windows-only crate, -619)extern "C"declarations that no Rust code references: the tcp/udp/tty/poll/prepare/check/fs_poll/threading/dl/os-info/metrics surface ofuv.h(uv_tcp_*,uv_udp_*,uv_tty_get_winsize,uv_prepare_*,uv_check_*,uv_fs_poll_*,uv_thread_*,uv_key_*,uv_once,uv_os_get_passwd,uv_os_environ,uv_queue_work,uv_getnameinfo,uv_random,uv_async_init,uv_dlopen, ...). The C symbols themselves stay exported for napi addons viasymbols.def/symbols.dyn/linker*.ldsand the force-link list innapi_body.rs; only bun's own unused Rust declarations go.uv_getnameinfo_t,uv_random_t,uv_timespec64_t,uv_timeval64_t,uv_dir_t,uv_dirent_t,uv_env_item_t,uv_passwd_t,uv_group_t,uv_metrics_t,uv_key_t,uv_once_t,uv_thread_options_t,uv_lib_t,uv_getnameinfo_cb,uv_random_cb,uv_fs_poll_cb,uv_thread_cb, plus theuv_sem_t/uv_errno_t/uv_handle_s/uv_loop_s/uv_run_mode/uv_pipe_t/uv_fs_s/struct_uv_req_s/struct_uv_stream_s/uv_dirent_type_t/FILE/uv_thread_t/uv_loop_option/uv_membership/uv_tty_vtermstate_t/uv_clock_idaliases.UvReqmarker trait and its 10 impls,Loop::dump_active_handles,Pipe::set_pending_instances_count,Pipe::as_stream_ptr,uv_async_t::init,uv_stat_t::birthtime.StdioFlags(the threeStdioFlags::INHERIT_FDuses inbun_spawnnow spellUV_INHERIT_FDlike the rest of that function),UV_FS_O_*(duplicates of theOmodule),UV_PRIORITY_*,UV_CLOCK_*,UV_LOOP_BLOCK_SIGNAL/UV_METRICS_IDLE_TIME, the udp/tty-mode/membership/copyfile flag groups,UV_MAXHOSTNAMESIZE,UV_IF_NAMESIZE,MAX_PIPENAME_LEN.bun_cares_sys(-118):ares_library_init,ares_version,ares_init,ares_set_socket_functions,ares_send,ares_search,ares_gethostbyname,ares_getsock,ares_timeout,ares_create_query,ares_expand_name,ares_expand_string,ares_parse_uri_reply,ares_free_string, theares_socket_functionsandstruct_ares_uri_replystructs, theares_ssize_t/struct_timevalaliases, two commented-outares_fds/ares_processdeclarations, and the Windowstimeval/iovecdefinitions inlib.rsthat existed only for them.bun_brotli_sys:BrotliDecoder::{is_finished, get_error_code, version}and theBrotliDecoderIsFinished/BrotliDecoderVersiondeclarations (callers useBrotliDecoderGetErrorCodedirectly).simdutf FFI (-230): 22 unused declarations in
simdutf.rsand 30 wrappers inbun-simdutf.cpp(the 22 plus 8 that had already lost their Rust declaration), and their stubs in the parser bench shim. The lint asserts the two files now declare exactly the same set ofsimdutf__*names.bun_runtimetest_runner::expect::JSValueTestExt: 17 forwarder methods (to_fmt,jest_deep_equals,values,keys,to_u32, ...) thatbun_jsc::JSValueinherent methods of the same name shadow, so no call site ever resolved to them; rustc reports them unused once the trait is scoped to the crate. The four methods that do add behavior stay.CustomMatcherParamsFormatter::global_this(and its now-unused lifetime),SuccessfulReturnsFormatter::global_this,FetchOptions::global_this.S3ErrorJsc::to_js(every caller uses thes3_error_to_jsfree fn).C++ bindings (roughly -590)
Events_functionGetEventListeners/ListenerCount/Once/OninJSEventEmitter.cpp(declared in the header, never installed anywhere) andjsEventEmitterCast+JSEventEmitterWrapper, whose only callers they were.jsEventEmitterCastFastis untouched.jsFunctionDebugNoop,jsFunctionSyncBuiltinExports(NodeModuleModule.cpp; the live export isjsFunctionSyncBuiltinESMExports).jsCookieStaticFunctionSerialize(never attached to the constructor; onlyparse/fromare) plus its helperstoCookieWrappedandCookie::serialize(VM&, span<Ref<Cookie>>). The prototypeserialize()is untouched.JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGet*)declarations with no definition.UTF8Encoding(),createMockResultStructure(theLazyPropertyinitializer inlines the same code),ActiveDOMObject::queueTaskToDispatchEventand thequeueTaskToDispatchEventInternal/isAllowedToRunScript/PendingActivity::objecthelpers that became unreferenced with it,StreamQueue::setTotalSize,WorkerMessagingProxy::{askedToTerminate, loaderContextIdentifier, workerThread}getters, 19m_subspaceFor*/m_clientSubspaceFor*slots no class allocates from, thecommonStringInitializertypedef, theBUN_FOREACH_CJS_NATIVE_MODULEmacro, aDocumentLoadTimingforward declaration.CrossRealmTransform.cpp/WebStreamsInternals.h, which only threw "not implemented" and had no callers, plusCrossRealmMessageType.WebStreamsInternals.hdescribed these signatures as frozen placeholders from the streams port; nothing reaches them, so they are deleted here, but this is the one group in the PR that is a judgment call rather than a leftover, so it is easy to drop if you would rather keep the placeholders.EventInterfaces.h/EventTargetInterfaces.h: checked-in copies of WebCore's generated enums listing every event and event-target interface in WebKit. Trimmed to the 5 + 9 entries bun'sEvent/EventTargetsubclasses report; survivors keep their numeric values (Event::m_eventInterfaceis a 7-bit field, andEventFactory.cpp/EventTargetFactory.cppboth havedefault:arms).Verification
rgacrosssrc/,scripts/,test/,packages/and the regeneratedbuild/debug/codegen/output (plus substring searches for token-pasted names andvendor/WebKit/Sourcefor anythingextern "C").pubitems topub(crate)and intersecting rustc'sdead_codeoutput across all 8 target families, so platform-specific items (e.g.EmptyCopyFileStateon darwin,Listener::NamedPipeon Windows) were excluded automatically;bun_libuv_syswas evaluated on the Windows targets since the module iscfg(windows).cargo check --workspaceon all 10 CI triples,cargo check --workspace --tests,cargo fmt --check, clippy on the touched crates, fullbun bd, andbun bd testover events, cookies, node:module, TextEncoder/TextDecoder, expect.extend, toHaveReturnedWith, streams, fetch, zlib/brotli, mock, andtest/internal/source-lints/(the dns file's 30 network-dependent tests fail in the sandbox with ENOTFOUND both before and after; its 92 offline tests pass).test/internal/source-lints/dead-symbols-ffi-sys-test-runner-cpp.test.tspins 67 of the removed symbols (every entry was checked to match onmainand not on this branch).Notes for whoever merges
RETURN_IF_EXCEPTIONlines inside theEvents_function*bodies deleted here (its actual fix is injsEventEmitterCastFast, which this PR does not touch); whichever lands second needs a trivial rebase that drops those hunks.VM::has_termination_request,JSPromise::settle_task,job.rson_js_thread/off_thread(all added two days ago in Worker / worker_threads: WebCore-shaped lifetimes, joined threads, one ordered VM teardown #37075, presumably for follow-ups);JSC__VM__hasTerminationRequestgoes with them. Single unconstructed variants / unread payloads inside otherwise-live ABI or ported enums (SSRKind::Regular,DeclarationContext::Keyframes,StmtListWhich::AllStmts,OptionsData::Saved(usize),AsyncState::Done(ExitCode)) and the remaining partially-used libuv constant tables were also left as-is. rustc's "field is never read" hits onmulti_array_columns!schema structs (JSMeta,BuilderEntry,LineOffsetTable,ServerComponentBoundary, the isolated-installEntry,BundledAst::tla_check) and on the type-punnedSerializedSourceMapLoadedare live data, not dead code.[review] gate passed · iteration 0 · 43 files touched
fails on main (without fix)
passes on PR (with fix)
diff hotspot
gate history · 4 passed · 0 rejected · iteration 0
evidence per changed file