Skip to content

Remove dead code from the JSC, WebCore, and node bindings, uWS/uSockets, SecretsLinux, and seven Rust crates - #42431

Open
robobun wants to merge 5 commits into
mainfrom
robobun/bb9ba3e6/dead-code-sweep
Open

robobun wants to merge 5 commits into
mainfrom
robobun/bb9ba3e6/dead-code-sweep

Conversation

@robobun

@robobun robobun commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Behaviour change: none

Problem

  • About 735 lines are unreachable. Examples: the _ZTVN7WebCore15AbortControllerE vtable declarations behind ENABLE(BINDING_INTEGRITY) (used only inside a comment), uws_app_run (its Rust importer left in Remove 77 pub items that nothing uses on any platform #42078), and 9 dlsym results in SecretsLinux.cpp that nothing reads.
  • rustc, clang, and hawk do not flag them: pub link-interface methods, extern "C" definitions, inline members, write-only fields, commented-out code.

Fix

  • Delete each item and its knock-on declarations. No edit changes what runs.
  • Correct because each symbol has zero references in src/, generated code, packages/, scripts/, and test/ on every platform.
  • Checked again after a merge of main at 5c6d4e2. Two deletions were stale and left the diff: us_quic_socket_close and the sqlite3_errcode entry of lazy_sqlite3.h (Notes).
  • Verified: bun bd, bun run rust:check-all (12 of 12 targets), test/internal/source-lints, and the suites in Notes.

Background

  • ENABLE(BINDING_INTEGRITY) is a WebKit bindings-generator check of a wrapped object's vtable pointer. Its body is commented out here, so the extern vtable declarations have no user.
  • bun_dispatch::link_interface! lets a low-tier crate call a high-tier crate. Each method becomes a #[no_mangle] export plus a pub fn dispatcher, which rustc's dead_code lint cannot see.

Downsides

  • A deletion can go stale while the PR waits: main started to use two deleted functions in six weeks. Only a green CI run on the current main checks the macOS-only and Windows-only code.
  • None found at runtime. No deleted symbol is exported (src/symbols.*), read from JS, or named by codegen.
Notes

WebCore bindings (206 lines)

  • JSAbortController.cpp, JSCloseEvent.cpp, JSPerformanceObserver.cpp, JSPerformanceTiming.cpp, JSWebSocket.cpp, JSWorker.cpp: the #if ENABLE(BINDING_INTEGRITY) vtable extern block, and the if constexpr (std::is_polymorphic_v<T>) block in toJSNewlyCreated whose body is comments only.
  • JSCustomEvent.cpp, JSPerformanceServerTiming.cpp: the vtable extern block.
  • Remove dead code from the WebCore bindings and 20 Rust crates #40525 removes the same block from 5 other files.

uWS and uSockets

  • uws_app_run (src/uws_sys/libuwsockets.cpp) and the members only it called: TemplatedApp::run(), Loop::run(), free uWS::run().
  • TemplatedApp::listen(int, handler) (packages/bun-uws/src/App.h). Its only caller, uws_app_listen, is already gone on main.
  • us_socket_pair, us_socket_open (socket.c), us_listen_socket_get_fd (context.c), and their prototypes. The Rust declarations left in Remove 77 pub items that nothing uses on any platform #42078.
  • struct uws_header_iterator_s; (_libusockets.h). A redundant extern "C" declaration in DevServerSourceProvider.cpp (the header declares it).

Top-level src/jsc/bindings

  • SecretsLinux.cpp: the pointers g_list_free_full, g_str_hash, g_str_equal, secret_service_search_sync, secret_item_get_secret, secret_value_get_text, secret_value_unref, secret_item_get_attributes, secret_item_load_secret_sync, their dlsym lines, and the types only they used (_GList body, SecretService, SecretValue, SecretItem, SecretSearchFlags). load_functions() keeps its check as it is.
  • wtf-bindings.cpp: the __sun / __MVS__ cfmakeraw fallback. No Bun target defines these macros.
  • c-bindings.cpp: the non-Linux preadv2 / pwritev2 ENOSYS stubs. Rust calls sys_preadv2 / sys_pwritev2 only under cfg(linux | android).
  • ZigGlobalObject.h, ZigGlobalObject.cpp, BakeGlobalObject.cpp: write-only isThreadLocalDefaultGlobalObject, the const guardedObjects() overload, the commented member m_JSBunDebuggerValue, duplicate forward declarations, using JSNonFinalObject, #undef JSC_TYPED_ARRAY_CHECK, commented-out lines.
  • headers-handwritten.h: the #ifndef __cplusplus branches (the header includes C++ headers before them, no .c file includes it) and the constants ZigStackFrameCodeNone, JSErrorCodeOutOfMemoryError, JSErrorCodeStackOverflow, JSErrorCodeUserErrorCode, BunLoaderTypeCSS, BunLoaderTypeFILE, BunLoaderTypeJSONC, BunLoaderTypeWASM.
  • bindings.cpp: FLAG_PROMISE_RESOLVES, FLAG_PROMISE_REJECTS and the -Wunused-variable pragma that existed for them, #undef IMPL_DEEP_EQUALS_WRAPPER, one commented-out line.
  • napi.h: the BoundFinalizer(const NapiFinalizer&, void*) constructor. napi_finalizer.h: hint().
  • InspectorLifecycleAgent: write-only m_preventingExit. ModuleLoader.h: write-only OnLoadResult::wasMock.
  • workaround-missing-symbols.cpp: the #define UNLIKELY block. root.h: the ENABLE_3D_TRANSFORMS #error guard (no WebKit header defines the flag, checked in the headers of the current WebKit version). ncrypto.h: CryptoErrorList::rbegin / rend, Cipher::MAX_KEY_LENGTH / MAX_IV_LENGTH. uv-posix-polyfills.c: the unreachable __CYGWIN__ branch. NodeVM.h: BaseVMOptions::failed. NodeVMScript.h: the cachedDataProduced(bool) setter. CallSite.h: Flags::IsWasm. DOMFormData.h: forward declarations of HTMLElement, HTMLFormElement.
  • Unused locals: identifier (BunObject.cpp), wrapperStart, wrapperEnd, exception (JSCommonJSModule.cpp), argList (InternalModuleRegistry.cpp).
  • 18 duplicate #include lines. For each, one copy stays in the same preprocessor scope.
  • Duplicate or unused extern "C" declarations: Bun__readOriginTimerStart (2), Bun__getTLSRejectUnauthorizedValue, Bun__Node__ProcessPendingDeprecation.
  • Commented-out code older than one year in JSDOMExceptionHandling.cpp, JSX509CertificatePrototype.cpp, BunClientData.h, JSWrappingFunction.cpp, JSDOMGlobalObject.h.

node, webcrypto, sqlite, v8

  • CryptoUtil.h: ByteSource::operator ncrypto::Buffer<const T>(), ByteSource::empty(), DSASigEnc::Invalid.
  • JSNodeHTTPServerSocketPrototype::createStructure. Unused uWS forward declarations, an orphaned doc comment, and two unused extern "C" prototypes in JSNodeHTTPServerSocket.{h,cpp}.
  • RsaKeyVariant::RSA_OAEP, KeyObject::KeyEncodingContext::Export, the const overloads JSDiffieHellman::getImpl, JSDiffieHellmanGroup::getImpl, JSKeyObject::handle, HTTP_BOTH, and commented-out declarations in JSSign.h, KeyObject.h, CryptoUtil.h, NodeHTTPParser.h.
  • webcrypto: CryptoAlgorithmParameters::Class::RsaKeyGenParams with its parametersClass() override and type-trait specialization (the class is only a base class), forward declarations CryptoKeyAKP and JSC::CallFrame, three commented-out lines.
  • sqlite: duplicate JSC_DECLARE_CUSTOM_GETTER lines in JSSQLStatement.cpp, a dead vm local in NodeSqlite.cpp.
  • v8 shim: shim::Handle::Handle(const ObjectLayout*), the private const FunctionTemplate::localToObjectPointer(), kInternalFieldsInWeakCallback, Oddball::Kind::kInvalid, four unused using declarations.

Rust

  • JsEventLoop::{file_polls, put_file_poll, stdout, stderr}: declarations in src/event_loop/lib.rs, impl arms in src/jsc/event_loop.rs.
  • ErrnoNames::win32_name, win32_errno_name, and its unit test (src/bun_core/lib.rs, src/errno/lib.rs). The callers left in Replace bun_core::Error intern machinery with per-crate thiserror enums #33909.
  • bun_windows_sys::externs: NtClose, IsProcessInJob, GetSystemInfo with SYSTEM_INFO, JobObjectAssociateCompletionPortInformation with JOBOBJECT_ASSOCIATE_COMPLETION_PORT, the empty user32 and advapi32 modules, and their re-exports in src/sys/windows/mod.rs. Every caller uses a local safe fn declaration.
  • The libc dependency of bun_paths.

Built-in JS

  • $defineProperties and ArrayBufferConstructor in src/js/builtins.d.ts.
  • Commented-out code older than one year in ConsoleObject.ts, Ipc.ts, undici.js, fifo.ts, tls.ts, stream.promises.ts, native-readable.ts, net.ts, dgram.ts, assert.ts, child_process.ts, cluster.ts.

Edits that are not whole-line deletions

  • packages/bun-uws/src/Loop.h: the file comment no longer names the removed run().
  • pub use lists in bun_windows_sys and src/sys/windows/mod.rs lose the removed names.
  • src/install/windows-shim/main.rs: a comment named w::ntdll::NtClose, which bun_windows_sys::ntdll no longer declares. It now names NtCreateFile.

Dropped in the merge with main (main at 5c6d4e2)

  • Stale, main uses the code again: us_quic_socket_close (src/uws_sys/quic/Socket.rs imports it since fetch: proxy, TLS identity and error fixes; add Bun.FetchSession #42692), and the sqlite3_errcode entry of lazy_sqlite3.h (JSSQLStatement.cpp calls it since sql: consolidate the open Bun.sql, bun:sqlite and node:sqlite pull requests #45304). git reported no conflict for either one.
  • The other three lazy_sqlite3.h entries (sqlite3_bind_blob, sqlite3_bind_text, sqlite3_bind_text16) are also out. They still have no caller, but the header compiles only on macOS and the sqlite bindings change often.
  • main changed or removed the code: scripts/azure.mjs, scripts/machine.mjs, scripts/runner.node.mjs, CommonJS.ts, ProcessObjectInternals.ts, sql.ts, BunPlugin.cpp, BakeAdditionsToGlobalObject.h, JSBakeResponse.cpp, uws_app_listen, the lazyLoadSQLite() stubs, the _flags parameter in net.ts.
  • Kept so that nothing observable changes: the 6 pointers that SecretsLinux.cpp load_functions() tests and never calls (their removal changes when Bun.secrets reports that libsecret is not available), and the debug-only globalThis.__getId in child_process.ts.

Found but not in this diff

  • NodeHTTPIncomingRequestType.FetchRequest / .FetchResponse in src/js/internal/http.ts: unused, but their removal renumbers NodeHTTPResponse from 2 to 0, and util.inspect(req) shows that value.
  • The commented-out captureRejection lines in _http_server.ts and http2.ts: node:http: emit 'error' for a captured rejection on a non-'request' Server event #41738 turns them into live code.
  • TransformOutstream in src/bundler/transpiler.rs: the value is threaded through two private functions and never read. Its removal leaves BundleOptions::output_dir_handle write-only while that field still owns the output directory fd, so both belong in one separate change.
  • call: true on the 7 noConstructor matcher classes in jest.classes.ts: Remove dead code from bun_jsc, bun_core, the bindgenv2 codegen, 15 error types, and the C++ bindings #40915 already changes it.
  • NullableInnerParameterType aliases in IDLTypes.h: dead after Remove dead code from the web streams bindings, the test runner formatter, and the bindgen codegen #41445 lands.
  • lsquic_sys Settings::scid_len / delay_onclose and their C shims: no caller, left because node:quic is in active work.
  • Write-only #[no_mangle] static Bun__Node__CAStore in Arguments.rs: no reader in C++.
  • ErrnoNames::max_dense: no caller, but its removal leaves SystemErrno::MAX test-only on Windows.
  • AsyncContextFrame.exchange in src/js/internal/async_context_frame.ts: no caller, mirrors Node's internal API.
  • About 35 Zig::*_getter functions from WEBCORE_GENERATED_CONSTRUCTOR_GETTER that lld discards. The macro needs a split.

How the deletions were checked after the merge

  • For each file, every identifier that the diff removes from that file completely was searched in the merged tree (src/, packages/, scripts/, test/, generated code). This search found the us_quic_socket_close import. The sqlite3_errcode call came from a report, because the call uses the macro name and not the lazy_ name. After that, each removed #define name was searched too.
  • For each removed duplicate #include or declaration, one copy is still present in the same preprocessor scope.
  • bun bd links. bun run rust:check-all passes on 12 of 12 targets. tsc --noEmit -p src/js/tsconfig.json passes. clang-format, rustfmt, and prettier report nothing on the changed files.
  • A second, independent pass read every removed hunk against the merged tree (platform branches, macro aliases, FFI, codegen, enum numbering) and found no remaining reference.
  • No deletion overlaps one of the 63 other open dead-code PRs (checked file by file against their diffs).

Tests run with the debug build on the merged tree

test/internal/source-lints (181 pass, the 2 failures are 5 s timeouts of sema-parser-recursion.test.ts under the ASAN debug build, that file passes with a release binary), test/js/bun/sqlite/sqlite.test.js, test/js/node/sqlite/node-sqlite.test.ts, test/js/web/abort/abort.test.ts, test/js/web/workers/worker.test.ts, test/js/web/workers/message-event.test.ts, test/js/web/websocket/websocket-client.test.ts, test/js/node/crypto/node-crypto.test.js, test/js/node/crypto/ecdh.test.ts, test/js/bun/http/serve-listen.test.ts, test/js/node/http/node-http.test.ts, test/js/node/net/node-net-server.test.ts, test/js/node/net/node-net.test.ts, test/js/node/child_process/child_process.test.ts, test/js/node/dgram/node-dgram.test.js, test/js/node/vm/vm.test.ts, test/js/bun/plugin/plugins.test.ts, test/js/first_party/undici/undici.test.ts, test/js/bun/test/mock-fn.test.js, test/js/web/console/console-log.test.ts, test/js/node/process/process-nexttick.test.js. The failures seen are 5 s timeouts that pass with --timeout 60000, tests that need the public internet (www.example.com), and Bun.secrets (no libsecret in the container).

…ckets, SecretsLinux, and five Rust crates

Every item has zero references on any platform (rg over src/, generated
code, packages/, scripts/, test/), and a relink of the debug binary with
--gc-sections discards the C/C++/Rust symbols removed here.

C++: inert ENABLE(BINDING_INTEGRITY) vtable blocks in 8 JS*.cpp wrappers,
15 dlsym'd libsecret/glib pointers nothing calls, the Solaris/z/OS
cfmakeraw fallback, the uws_app_listen/uws_app_run C API and their
uWS-only callees, four uSockets functions without callers, preadv2/pwritev2
ENOSYS stubs, write-only fields, unused constants, overloads, locals,
duplicate includes and declarations, and long-dead commented-out code.

Rust: unused JsEventLoop and ErrnoNames link-interface methods, the
TransformOutstream plumbing in the transpiler, duplicate Win32
declarations in bun_windows_sys, and the unused libc dependency of
bun_paths.

JS and scripts: unused locals, type declarations, enum variants, and
commented-out code.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between dff144b and 314f814.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 79
  • packages/bun-usockets/src/context.c
  • packages/bun-usockets/src/libusockets.h
  • packages/bun-usockets/src/socket.c
  • packages/bun-uws/src/App.h
  • packages/bun-uws/src/Loop.h
  • src/bun_core/lib.rs
  • src/errno/lib.rs
  • src/event_loop/lib.rs
  • src/install/windows-shim/main.rs
  • src/js/builtins.d.ts
  • src/js/builtins/ConsoleObject.ts
  • src/js/builtins/Ipc.ts
  • src/js/internal/streams/native-readable.ts
  • src/js/internal/tls.ts
  • src/js/node/assert.ts
  • src/js/node/child_process.ts
  • src/js/node/cluster.ts
  • src/js/node/dgram.ts
  • src/js/node/net.ts
  • src/js/thirdparty/undici.js
  • src/jsc/bindings/BunClientData.h
  • src/jsc/bindings/BunObject.cpp
  • src/jsc/bindings/BunProcess.cpp
  • src/jsc/bindings/CallSite.h
  • src/jsc/bindings/ConsoleObject.cpp
  • src/jsc/bindings/DOMFormData.h
  • src/jsc/bindings/InspectorLifecycleAgent.cpp
  • src/jsc/bindings/InspectorLifecycleAgent.h
  • src/jsc/bindings/InternalModuleRegistry.cpp
  • src/jsc/bindings/JSBuffer.cpp
  • src/jsc/bindings/JSBundlerPlugin.cpp
  • src/jsc/bindings/JSCommonJSModule.cpp
  • src/jsc/bindings/JSDOMExceptionHandling.cpp
  • src/jsc/bindings/JSEnvironmentVariableMap.cpp
  • src/jsc/bindings/JSMockFunction.cpp
  • src/jsc/bindings/JSWrappingFunction.cpp
  • src/jsc/bindings/JSX509CertificatePrototype.cpp
  • src/jsc/bindings/ModuleLoader.cpp
  • src/jsc/bindings/ModuleLoader.h
  • src/jsc/bindings/NodeHTTP.cpp
  • src/jsc/bindings/NodeVM.h
  • src/jsc/bindings/NodeVMScript.h
  • src/jsc/bindings/SecretsLinux.cpp
  • src/jsc/bindings/ZigGlobalObject.cpp
  • src/jsc/bindings/ZigGlobalObject.h
  • src/jsc/bindings/bindings.cpp
  • src/jsc/bindings/c-bindings.cpp
  • src/jsc/bindings/headers-handwritten.h
  • src/jsc/bindings/napi.cpp
  • src/jsc/bindings/napi.h
  • src/jsc/bindings/napi_finalizer.h
  • src/jsc/bindings/ncrypto.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.h
  • src/jsc/bindings/node/crypto/CryptoUtil.h
  • src/jsc/bindings/node/http/NodeHTTPParser.h
  • src/jsc/bindings/sqlite/JSSQLStatement.cpp
  • src/jsc/bindings/sqlite/NodeSqlite.cpp
  • src/jsc/bindings/uv-posix-polyfills.c
  • src/jsc/bindings/v8/V8Array.cpp
  • src/jsc/bindings/v8/V8Object.cpp
  • src/jsc/bindings/v8/node.cpp
  • src/jsc/bindings/v8/v8_api_internal.cpp
  • src/jsc/bindings/webcore/JSAbortController.cpp
  • src/jsc/bindings/webcore/JSCloseEvent.cpp
  • src/jsc/bindings/webcore/JSCustomEvent.cpp
  • src/jsc/bindings/webcore/JSPerformanceObserver.cpp
  • src/jsc/bindings/webcore/JSWebSocket.cpp
  • src/jsc/bindings/webcore/JSWorker.cpp
  • src/jsc/bindings/webcrypto/JSCryptoKey.cpp
  • src/jsc/bindings/webcrypto/JSSubtleCrypto.cpp
  • src/jsc/bindings/wtf-bindings.cpp
  • src/jsc/event_loop.rs
  • src/runtime/bake/BakeGlobalObject.cpp
  • src/sys/windows/mod.rs
  • src/uws_sys/_libusockets.h
  • src/uws_sys/libuwsockets.cpp
  • src/windows_sys/externs.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 06b859e2-77a1-4e0f-bf45-561428afc0c4

📥 Commits

Reviewing files that changed from the base of the PR and between a749e0a and 55f6a28.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (121)
  • packages/bun-usockets/src/context.c
  • packages/bun-usockets/src/libusockets.h
  • packages/bun-usockets/src/quic.c
  • packages/bun-usockets/src/quic.h
  • packages/bun-usockets/src/socket.c
  • packages/bun-uws/src/App.h
  • packages/bun-uws/src/Loop.h
  • scripts/azure.mjs
  • scripts/machine.mjs
  • scripts/runner.node.mjs
  • scripts/tart.mjs
  • src/bun_core/lib.rs
  • src/bundler/transpiler.rs
  • src/errno/lib.rs
  • src/event_loop/lib.rs
  • src/js/builtins.d.ts
  • src/js/builtins/CommonJS.ts
  • src/js/builtins/ConsoleObject.ts
  • src/js/builtins/Ipc.ts
  • src/js/builtins/ProcessObjectInternals.ts
  • src/js/bun/sql.ts
  • src/js/internal/fifo.ts
  • src/js/internal/http.ts
  • src/js/internal/stream.promises.ts
  • src/js/internal/streams/native-readable.ts
  • src/js/internal/tls.ts
  • src/js/node/_http_server.ts
  • src/js/node/assert.ts
  • src/js/node/child_process.ts
  • src/js/node/cluster.ts
  • src/js/node/dgram.ts
  • src/js/node/http2.ts
  • src/js/node/net.ts
  • src/js/thirdparty/undici.js
  • src/jsc/bindings/BakeAdditionsToGlobalObject.h
  • src/jsc/bindings/BunClientData.h
  • src/jsc/bindings/BunObject.cpp
  • src/jsc/bindings/BunPlugin.cpp
  • src/jsc/bindings/BunProcess.cpp
  • src/jsc/bindings/CallSite.h
  • src/jsc/bindings/ConsoleObject.cpp
  • src/jsc/bindings/DOMFormData.h
  • src/jsc/bindings/InspectorLifecycleAgent.cpp
  • src/jsc/bindings/InspectorLifecycleAgent.h
  • src/jsc/bindings/InternalModuleRegistry.cpp
  • src/jsc/bindings/JSBakeResponse.cpp
  • src/jsc/bindings/JSBuffer.cpp
  • src/jsc/bindings/JSBundlerPlugin.cpp
  • src/jsc/bindings/JSCommonJSModule.cpp
  • src/jsc/bindings/JSDOMExceptionHandling.cpp
  • src/jsc/bindings/JSDOMGlobalObject.h
  • src/jsc/bindings/JSEnvironmentVariableMap.cpp
  • src/jsc/bindings/JSMockFunction.cpp
  • src/jsc/bindings/JSWrappingFunction.cpp
  • src/jsc/bindings/JSX509CertificatePrototype.cpp
  • src/jsc/bindings/ModuleLoader.cpp
  • src/jsc/bindings/ModuleLoader.h
  • src/jsc/bindings/NodeHTTP.cpp
  • src/jsc/bindings/NodeVM.h
  • src/jsc/bindings/NodeVMScript.h
  • src/jsc/bindings/SecretsLinux.cpp
  • src/jsc/bindings/ZigGlobalObject.cpp
  • src/jsc/bindings/ZigGlobalObject.h
  • src/jsc/bindings/bindings.cpp
  • src/jsc/bindings/c-bindings.cpp
  • src/jsc/bindings/headers-handwritten.h
  • src/jsc/bindings/napi.cpp
  • src/jsc/bindings/napi.h
  • src/jsc/bindings/napi_finalizer.h
  • src/jsc/bindings/ncrypto.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.h
  • src/jsc/bindings/node/crypto/CryptoGenRsaKeyPair.h
  • src/jsc/bindings/node/crypto/CryptoUtil.h
  • src/jsc/bindings/node/crypto/JSDiffieHellman.h
  • src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.h
  • src/jsc/bindings/node/crypto/JSKeyObject.h
  • src/jsc/bindings/node/crypto/JSSign.h
  • src/jsc/bindings/node/crypto/KeyObject.h
  • src/jsc/bindings/node/http/NodeHTTPParser.h
  • src/jsc/bindings/root.h
  • src/jsc/bindings/sqlite/JSSQLStatement.cpp
  • src/jsc/bindings/sqlite/NodeSqlite.cpp
  • src/jsc/bindings/sqlite/lazy_sqlite3.h
  • src/jsc/bindings/uv-posix-polyfills.c
  • src/jsc/bindings/v8/V8Array.cpp
  • src/jsc/bindings/v8/V8FunctionTemplate.cpp
  • src/jsc/bindings/v8/V8FunctionTemplate.h
  • src/jsc/bindings/v8/V8Object.cpp
  • src/jsc/bindings/v8/node.cpp
  • src/jsc/bindings/v8/shim/Handle.cpp
  • src/jsc/bindings/v8/shim/Handle.h
  • src/jsc/bindings/v8/shim/Oddball.h
  • src/jsc/bindings/v8/v8_api_internal.cpp
  • src/jsc/bindings/v8/v8_api_internal.h
  • src/jsc/bindings/webcore/JSAbortController.cpp
  • src/jsc/bindings/webcore/JSCloseEvent.cpp
  • src/jsc/bindings/webcore/JSCustomEvent.cpp
  • src/jsc/bindings/webcore/JSPerformanceObserver.cpp
  • src/jsc/bindings/webcore/JSPerformanceServerTiming.cpp
  • src/jsc/bindings/webcore/JSPerformanceTiming.cpp
  • src/jsc/bindings/webcore/JSWebSocket.cpp
  • src/jsc/bindings/webcore/JSWorker.cpp
  • src/jsc/bindings/webcrypto/CryptoAlgorithmMLKEM.h
  • src/jsc/bindings/webcrypto/CryptoAlgorithmParameters.h
  • src/jsc/bindings/webcrypto/CryptoAlgorithmRsaKeyGenParams.h
  • src/jsc/bindings/webcrypto/CryptoKeyOKPOpenSSL.cpp
  • src/jsc/bindings/webcrypto/JSCryptoKey.cpp
  • src/jsc/bindings/webcrypto/JSSubtleCrypto.cpp
  • src/jsc/bindings/webcrypto/SubtleCrypto.h
  • src/jsc/bindings/workaround-missing-symbols.cpp
  • src/jsc/bindings/wtf-bindings.cpp
  • src/jsc/event_loop.rs
  • src/paths/Cargo.toml
  • src/runtime/bake/BakeGlobalObject.cpp
  • src/runtime/bake/DevServerSourceProvider.cpp
  • src/sys/windows/mod.rs
  • src/uws_sys/_libusockets.h
  • src/uws_sys/libuwsockets.cpp
  • src/windows_sys/externs.rs
💤 Files with no reviewable changes (112)
  • src/js/internal/stream.promises.ts
  • src/jsc/bindings/v8/v8_api_internal.h
  • src/jsc/bindings/v8/V8FunctionTemplate.h
  • packages/bun-usockets/src/quic.h
  • src/jsc/bindings/JSDOMExceptionHandling.cpp
  • src/js/internal/fifo.ts
  • src/jsc/bindings/uv-posix-polyfills.c
  • src/jsc/bindings/BunClientData.h
  • src/js/thirdparty/undici.js
  • src/jsc/bindings/v8/shim/Oddball.h
  • src/paths/Cargo.toml
  • src/jsc/bindings/ModuleLoader.h
  • src/jsc/bindings/BakeAdditionsToGlobalObject.h
  • src/jsc/bindings/v8/shim/Handle.h
  • src/js/internal/streams/native-readable.ts
  • src/jsc/bindings/BunPlugin.cpp
  • src/jsc/bindings/JSX509CertificatePrototype.cpp
  • src/jsc/bindings/NodeVM.h
  • src/jsc/bindings/JSMockFunction.cpp
  • src/jsc/bindings/root.h
  • src/jsc/bindings/webcrypto/CryptoAlgorithmParameters.h
  • src/jsc/bindings/v8/V8Array.cpp
  • packages/bun-usockets/src/context.c
  • src/js/bun/sql.ts
  • src/jsc/bindings/webcrypto/JSSubtleCrypto.cpp
  • src/jsc/bindings/webcore/JSPerformanceServerTiming.cpp
  • src/jsc/bindings/NodeHTTP.cpp
  • src/jsc/bindings/webcrypto/CryptoKeyOKPOpenSSL.cpp
  • src/runtime/bake/DevServerSourceProvider.cpp
  • src/jsc/bindings/InternalModuleRegistry.cpp
  • src/jsc/bindings/node/crypto/CryptoGenRsaKeyPair.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.h
  • src/jsc/bindings/v8/V8Object.cpp
  • src/js/node/http2.ts
  • src/uws_sys/_libusockets.h
  • src/jsc/bindings/webcrypto/SubtleCrypto.h
  • src/jsc/bindings/napi_finalizer.h
  • src/jsc/bindings/webcore/JSCloseEvent.cpp
  • src/jsc/bindings/JSBundlerPlugin.cpp
  • src/jsc/bindings/workaround-missing-symbols.cpp
  • src/jsc/bindings/node/crypto/JSSign.h
  • src/jsc/bindings/v8/node.cpp
  • src/js/node/dgram.ts
  • src/jsc/bindings/InspectorLifecycleAgent.cpp
  • src/js/builtins.d.ts
  • src/jsc/bindings/webcore/JSPerformanceTiming.cpp
  • src/jsc/bindings/InspectorLifecycleAgent.h
  • src/jsc/bindings/BunProcess.cpp
  • packages/bun-uws/src/App.h
  • src/jsc/bindings/NodeVMScript.h
  • src/js/internal/http.ts
  • src/jsc/bindings/ModuleLoader.cpp
  • src/js/node/_http_server.ts
  • src/jsc/bindings/ncrypto.h
  • src/js/node/child_process.ts
  • packages/bun-usockets/src/quic.c
  • packages/bun-usockets/src/socket.c
  • src/jsc/bindings/JSBakeResponse.cpp
  • src/jsc/bindings/JSBuffer.cpp
  • src/jsc/bindings/ConsoleObject.cpp
  • src/jsc/bindings/v8/V8FunctionTemplate.cpp
  • src/uws_sys/libuwsockets.cpp
  • src/jsc/bindings/DOMFormData.h
  • src/jsc/bindings/webcore/JSWorker.cpp
  • src/bun_core/lib.rs
  • src/jsc/bindings/CallSite.h
  • src/jsc/bindings/webcore/JSAbortController.cpp
  • src/jsc/bindings/c-bindings.cpp
  • src/js/builtins/ConsoleObject.ts
  • src/runtime/bake/BakeGlobalObject.cpp
  • src/jsc/bindings/webcore/JSWebSocket.cpp
  • src/jsc/bindings/node/crypto/JSKeyObject.h
  • src/jsc/bindings/webcore/JSCustomEvent.cpp
  • src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.h
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp
  • src/jsc/bindings/v8/shim/Handle.cpp
  • src/js/builtins/Ipc.ts
  • src/jsc/bindings/JSWrappingFunction.cpp
  • src/js/builtins/CommonJS.ts
  • src/jsc/bindings/bindings.cpp
  • src/js/node/cluster.ts
  • src/event_loop/lib.rs
  • src/jsc/bindings/node/crypto/JSDiffieHellman.h
  • src/js/node/assert.ts
  • src/jsc/bindings/v8/v8_api_internal.cpp
  • src/jsc/bindings/sqlite/NodeSqlite.cpp
  • src/jsc/bindings/webcrypto/CryptoAlgorithmRsaKeyGenParams.h
  • src/errno/lib.rs
  • src/jsc/bindings/napi.h
  • src/jsc/bindings/node/http/NodeHTTPParser.h
  • src/jsc/bindings/node/crypto/KeyObject.h
  • scripts/tart.mjs
  • src/jsc/bindings/sqlite/JSSQLStatement.cpp
  • src/jsc/bindings/sqlite/lazy_sqlite3.h
  • src/jsc/bindings/JSEnvironmentVariableMap.cpp
  • src/jsc/bindings/ZigGlobalObject.h
  • src/jsc/bindings/webcrypto/JSCryptoKey.cpp
  • src/jsc/bindings/headers-handwritten.h
  • packages/bun-usockets/src/libusockets.h
  • src/jsc/bindings/JSDOMGlobalObject.h
  • src/jsc/bindings/webcrypto/CryptoAlgorithmMLKEM.h
  • src/jsc/bindings/webcore/JSPerformanceObserver.cpp
  • src/jsc/bindings/wtf-bindings.cpp
  • src/jsc/event_loop.rs
  • src/jsc/bindings/node/crypto/CryptoUtil.h
  • src/jsc/bindings/BunObject.cpp
  • src/jsc/bindings/napi.cpp
  • src/jsc/bindings/JSCommonJSModule.cpp
  • src/js/builtins/ProcessObjectInternals.ts
  • src/jsc/bindings/node/JSNodeHTTPServerSocket.h
  • src/jsc/bindings/ZigGlobalObject.cpp
  • src/js/internal/tls.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

The pull request removes unused public APIs, binding declarations, compatibility branches, stale comments, and redundant implementation code across networking, runtime, JavaScript, JSC bindings, SQLite, WebCrypto, V8, and Windows integrations.

Changes

API and binding surface cleanup

Layer / File(s) Summary
Networking and loop API removal
packages/bun-usockets/*, packages/bun-uws/*, src/uws_sys/*
Removes unused socket, QUIC, listen, loop, and uWS application entry points.
Script provisioning and bundler plumbing
scripts/*, src/bundler/transpiler.rs
Removes unused script variables, password-based cloud-init setup, and obsolete output-stream plumbing.
Runtime and event interface reduction
src/bun_core/lib.rs, src/errno/lib.rs, src/event_loop.*, src/js/builtins/*
Removes Win32 errno mapping, file-poll and stream accessors, obsolete cache state, and unused JavaScript declarations.
JavaScript source cleanup
src/js/node/*, src/js/thirdparty/undici.js, src/js/internal/*
Removes stale comments, debug state, unused parameters, and obsolete declarations.
JSC binding declarations and state cleanup
src/jsc/bindings/*
Removes unused includes, declarations, fields, comments, and exit-prevention state.
Global object and header contract cleanup
src/jsc/bindings/headers-handwritten.h, src/jsc/bindings/napi*, src/jsc/bindings/ncrypto.h
Reduces handwritten header contracts and removes unused N-API and crypto helper members.
SQLite and V8 binding simplification
src/jsc/bindings/sqlite/*, src/jsc/bindings/v8/*
Removes unused SQLite lazy bindings and simplifies V8 shim interfaces.
WebCore and WebCrypto binding changes
src/jsc/bindings/webcore/*, src/jsc/bindings/webcrypto/*
Removes binding-integrity validation scaffolding and unused WebCrypto declarations.
Platform and system export cleanup
src/jsc/bindings/*, src/paths/Cargo.toml, src/runtime/*, src/sys/windows/*, src/windows_sys/*
Removes obsolete platform fallbacks, dependencies, declarations, and Windows re-exports.

Possibly related PRs

  • oven-sh/bun#36742: Removes related file-poll lifecycle and platform event-loop declarations.

Suggested reviewers: jarred-sumner

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 55f6a

The removals retain the described active interfaces and behavior, with no current merge-blocking risk identified.

Pre-merge checks: Passed 4
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 names the main change, removing dead code across several binding and crate areas. It is specific enough for a teammate scanning history. The changeset removes dead code across JSC, WebCore, …
Description check Passed The description follows the template's two required sections. The 'What does this PR do?' content is present as Problem, Fix, Background, and Downsides, and the 'How did you verify your code works?' c…
Full details: Title check

Explanation

The title names the main change, removing dead code across several binding and crate areas. It is specific enough for a teammate scanning history. The changeset removes dead code across JSC, WebCore, node, uWS/uSockets, SecretsLinux, and Rust crates, and the title lists those areas. It is somewhat long and lists many areas, but it still conveys the primary change.

Full details: Description check

Explanation

The description follows the template's two required sections. The 'What does this PR do?' content is present as Problem, Fix, Background, and Downsides, and the 'How did you verify your code works?' content is present in Fix (Verified bullet) and a detailed Notes section listing test suites, build checks, and the rust:check-all run. The description is thorough and specific. The heading names differ from the template, and the 'What does this PR do?' heading is not used verbatim, but the required information is covered.

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.

@robobun

robobun commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: scheduled dead-code sweep, rebuilt on main at 5c6d4e2.

The branch was 588 commits behind main. A merge showed two deletions that main had made live again:

Both are restored, and every other deletion was checked again against the merged tree. The Notes block of the description lists what left the diff and how the check was done.

On the merged tree bun bd links, bun run rust:check-all passes on 12 of 12 targets, tsc --noEmit -p src/js/tsconfig.json passes, and test/internal/source-lints passes apart from two 5 s timeouts under the debug build (that file passes with a release binary).

The diff has no test/ change. It only deletes code that nothing references, and the description declares no behaviour change.

A green CI run on this push is the check for the macOS-only and Windows-only code. If the PR waits again, it needs a new merge of main and a new check before it merges.

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

I reviewed this PR and didn't find any bugs. Because it's a 122-file sweep across many independent subsystems (uWS/uSockets C API, JSC bindings, five Rust crates, src/js builtins) and touches a CODEOWNER'd path (src/js/builtins.d.ts), a human look is still worthwhile.

What was reviewed:

  • Grepped for remaining callers of every deleted extern "C" symbol (us_socket_pair, us_socket_open, us_listen_socket_get_fd, us_quic_socket_close, uws_app_listen, uws_app_run) and the removed link_interface! hooks (win32_name, file_polls, put_file_poll, stdout, stderr) — none remain.
  • Verified the removed bun_windows_sys externs (NtClose, IsProcessInJob, SYSTEM_INFO/GetSystemInfo, JOBOBJECT_ASSOCIATE_COMPLETION_PORT) are not the declarations the remaining call sites use (those declare their own locally).
  • Confirmed the relaxed SecretsLinux::loadFunctions() predicate now checks exactly the five pointers the file dereferences; the dropped checks were for pointers no code path calls.
  • Confirmed internalConnect in net.ts has no caller passing the removed _flags arg, and the removed headers-handwritten.h include in ZigGlobalObject.h was a duplicate (line 55 remains).
Extended reasoning...

Overview

This PR is a repo-wide dead-code sweep: +37/−906 across 122 files in a single commit. It removes unused C entry points from bun-usockets/bun-uws and their prototypes, prunes unused bun_dispatch::link_interface! hooks and their link_impl arms, drops the TransformOutstream enum and its parameter threading from bundler/transpiler.rs, strips unused Win32 externs/structs from windows_sys, removes 15 never-called dlsym pointers and associated types from SecretsLinux.cpp (relaxing the load-success predicate to only the functions actually used), deletes the fully-commented-out ENABLE(BINDING_INTEGRITY) scaffolding from seven webcore wrappers, and removes assorted unused includes, forward declarations, enum values, member fields, and commented-out code across dozens of C++ bindings and src/js builtins.

Security risks

Low. The only non-deletion edit is the SecretsLinux::loadFunctions() predicate, which now returns success when fewer dlsym lookups succeed. I verified the five remaining checks (g_error_free, secret_password_store_sync, secret_password_lookup_sync, secret_password_clear_sync, secret_password_free) are exactly the pointers the rest of the file dereferences, so this cannot introduce a null-deref and only widens the set of libsecret installs Bun accepts — a strictly safer direction. Crypto/TLS header changes remove only unused const overloads, enum values with no switch consumers, and commented-out declarations; no live cipher/key/verification path is touched. The removed preadv2/pwritev2 ENOSYS stubs on non-Linux are unreachable (Rust only calls the sys_-prefixed variants under cfg(linux|android)).

Level of scrutiny

Moderate-to-high. REVIEW.md explicitly calls out that public items and extern "C" symbols escape dead-code lints and require manual grep verification, which I performed for the highest-risk deletions (uSockets C API, link-interface hooks, Windows externs, sqlite lazy-load entries). All spot-checks confirmed zero remaining callers in src/, packages/, and generated code. The PR description's methodology (--gc-sections --print-gc-sections relink, rust:check-all across 12 targets) is the right proof for this class of change. The deleted win32_errno_names unit test is acceptable per REVIEW.md — it tested only the function being deleted, and the deletion is stated in the PR description.

Other factors

The .github/CODEOWNERS file assigns *.d.ts to a code owner, and this PR touches src/js/builtins.d.ts — per the approval guidelines, CODEOWNER-covered paths should not be auto-approved. Beyond that, 122 files across uSockets C, uWS C++, JSC bindings, webcrypto, v8 shim, five Rust crates, and CI provisioning scripts is broad enough that a human skim of the areas they own is prudent even though the automated hunt ran to dry_streak with no findings. The removed #include lines and forward declarations in widely-included headers (ZigGlobalObject.h, root.h) compiled per the PR's stated bun bd verification, but that's the kind of thing where a maintainer glance at their subsystem is cheap insurance.

@robobun

robobun commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 12:33 PM PT - Oct 23rd, 2026

✅ @robobun, your commit 314f81441baa23a897211e8772de68067840aae1 passed in Build #131409! 🎉


🧪   To try this PR locally:

bunx bun-pr 42431

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

bun-42431 --bun

- src/js/internal/http.ts: dropping the two unused enum variants
  renumbers NodeHTTPResponse from 2 to 0, and that value is visible on
  IncomingMessage through util.inspect.
- src/js/node/_http_server.ts, src/js/node/http2.ts: #41738 turns the
  commented captureRejection lines into live code.
- scripts/tart.mjs: #29315 already removes the rdp closure.
Comment thread src/bundler/transpiler.rs Resolved
Its removal leaves BundleOptions::output_dir_handle write-only while the
field still owns the output directory fd, and rustfmt re-indents an
unrelated match. Both belong in a separate change.

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

Code review found no issues

No high-confidence issues detected in this change.

Jarred-Sumner pushed a commit that referenced this pull request Sep 26, 2026
… and the CI pipeline script (#43976)

Behaviour change: none

### Problem
- Eleven files hold items that nothing reads or calls: write-only
fields, an uncalled method, four unused types, and CI options that are
parsed and dropped.
- No tool reports them. C and C++ have no dead-code lint. TypeScript
counts `x += n` as a read. The Rust types come from a macro.

### Fix
- TypeScript: remove `DataViewReader.u16()`, `DataViewWriter.capacity`,
the `totalCount` local in `updateBuildErrorOverlay`, and a commented-out
block from 2024 in `src/js/node/dgram.ts`.
- C and C++: remove `us_udp_socket_t.connected`,
`us_quic_stream_s.headers_delivered` and `Http2ResponseData::totalSize`
(each is only written), and `#undef FD_BITS` (nothing defines it).
- Rust and CI: remove the opaque types `us_loop_t`,
`us_socket_context_t`, `us_udp_socket_t`, `us_udp_packet_buffer_t` from
`src/uws_sys/lib.rs`. In `.buildkite/ci.ts`, remove `dryRun`,
`Platform.features`, four emoji entries, and the union members
`"amazonlinux"` and `"eol"`.
- Verified: `rg -w` for each symbol over `src`, `packages`, `scripts`,
`test` and `build/debug/codegen` finds no other use. `bun bd`, `bun run
rust:check-all` (12 targets) and `tsc` pass. Self-reviewed: 1 concern
raised, 1 addressed.

### Background
- `DataViewReader` and `DataViewWriter` decode and encode the binary
messages between the dev server and its browser client.
- `us_udp_socket_t` and `us_quic_stream_s` are private C structs of
uSockets. Rust holds them as opaque pointers, so no Rust struct mirrors
their layout.
- `bun_core::opaque_extern!` declares a zero-sized Rust type for a C
struct. Rust code names `Loop`, `udp::Socket` and `udp::PacketBuffer`,
not the four removed types.

### Downsides
- None found. Checked each removed symbol for users in Rust, C, C++,
TypeScript, generated code, tests, and open pull requests.

<details><summary>Notes</summary>

**Evidence per removal**

| Item | Evidence |
| --- | --- |
| `DataViewReader.u16()` | `rg '\.u16\('` over `src/runtime/bake`,
`test/bake`, `test/cli/inspect`: no hit. |
| `DataViewWriter.capacity` | The only hit of `.capacity` in the bake
TypeScript is the assignment in the constructor. `initCapacity` is the
only caller of the constructor. |
| `totalCount` | Two hits: the declaration and one `+=`. |
| `dgram.ts` block | `git blame`: 589f941, 2024-04-26.
`replaceHandle` and `startListening` are not defined in the file. |
| `us_udp_socket_t.connected` | Two hits, both `udp->connected = 0;`. |
| `us_quic_stream_s.headers_delivered` | Two hits in `quic.c`: the field
and one `= 1`. The struct is private to `quic.c`. |
| `Http2ResponseData::totalSize` | One member access: `data.totalSize =
totalSize;`. The other hits of `totalSize` are the function parameter. |
| `#undef FD_BITS` | The only hit of `FD_BITS` in `src` and `packages`.
|
| Four opaque types | Each name has one non-comment hit in all Rust
sources and generated Rust: the macro call. |
| `dryRun` | Four hits in `ci.ts`: the field, two assignments, one
destructure. Nothing reads the binding. |
| `Platform.features` | One hit. |
| Emoji, `Distro`, `Tier` entries | No platform in `ci.ts` or image in
`scripts/build/ci-images/spec.ts` carries them. `Emoji` is `keyof typeof
emojiMap`, so a remaining caller would fail `tsc -p
scripts/tsconfig.json`. It passes. |

**Taken out because an open pull request uses or removes the item**

- `DataViewWriter.u8()`: dead on main, but #42075 adds its first caller
(`check.u8(IncomingMessageId.check_errors)` in `hmr-runtime-error.ts`).
Git merges the two without a conflict, so the method stays. The tree
that results from a merge of this branch with #42075 has no type error
for `u8`.
- `declare module "bun:wrap"` in `bake.private.d.ts`: no importer, but
#39488 already has the same hunk.

**Tests run with the debug build, all pass**

`test/js/bun/udp/udp_socket.test.ts` (218),
`test/js/bun/udp/dgram.test.ts` (62),
`test/js/bun/http/serve-http2.test.ts` (93),
`test/js/bun/http/serve-http3.test.ts` (73),
`test/bake/dev/bundle.test.ts` (23), `test/bake/dev/esm.test.ts` (17),
`test/bake/hmr-socket-protocol.test.ts` (4),
`test/cli/inspect/BunFrontendDevServer.test.ts` (7).
`test/js/node/dgram/node-dgram.test.js` passes 3 of 4: the IPv6
multicast test fails with `ENODEV` in the test container, with and
without this change. `prettier` and `cargo fmt --check` report no
change.

**Overlap with open pull requests**

Each removed line was compared with the diffs of the 35 open dead-code
pull requests. None removes the same lines. Five files are also touched
by an open pull request, in hunks more than 6 lines away: `internal.h`
and `quic.c` (#40294, #42431), `dgram.ts` (#42431), `overlay.ts`
(#43378, #42075, #39488), `src/uws_sys/lib.rs` (#43010). The added lines
of the 122 open pull requests that were updated since 2026-09-18 and
touch the bake, uSockets, uWS, uws_sys, server, socket or CI sources
name none of the removed symbols.

**What was scanned**

- C and C++: the debug binary was linked a second time with
`--gc-sections`, and the two symbol tables were compared. 414 functions
in bun's own C and C++ are unreachable on Linux. Open pull requests
remove 263 of them. The remainder is in the list below, has a caller on
Windows or macOS, or comes from a macro.
- Rust: 37 `#[no_mangle]` exports are unreachable in the Linux link.
Each has a caller on another platform, or #40824, #40232 or #40557
removes it. A count of references for all 58,055 Rust definitions found
no other item without a user. Of the 144 `allow` attributes for the
unused and unreachable lints, each covers code that depends on `cfg` or
is macro output.
- Cargo: five dependency edges are unused on all 12 targets. #40294
removes three. `bun_resolver -> bun_zstd` is used under
`cfg(bun_codegen_embed)`. `bun_wyhash -> bstr` is used by unit tests.
- Preprocessor: `USE(BIGINT32)` and `ENABLE(MALLOC_BREAKDOWN)` are never
true. #43644 and #40557 remove those branches.
- Also scanned and clean: `src/js`, `src/node-fallbacks`, `src/codegen`,
`scripts/`, `misctools/`, `patches/` (every patch file has a user),
`packages/` except `bun-types`.

**Probably dead, left alone on purpose**

- The `PerformanceResourceTiming` cluster under
`src/jsc/bindings/webcore` (about 2,000 lines:
`PerformanceResourceTiming`, `PerformanceServerTiming`,
`ResourceTiming`, `NetworkLoadMetrics`, `ResourceLoadTiming`,
`ServerTiming` and the two JS wrappers). The linker drops every
constructor, so no instance can exist. The two globals are public and
`test/js/web/web-globals.test.js` checks them. This needs a decision:
keep it for a future resource-timing implementation, or reduce it to the
two constructors.
- `WEBCORE_GENERATED_CONSTRUCTOR_GETTER` (`ZigGlobalObject.cpp`) emits
an `X_getter` function for 50 classes. 45 have no user. A removal needs
a second macro and saves no source lines.
- The WebIDL converters for `byte`, `short` and `long long`, and most
`Clamp` and `EnforceRange` specializations in `JSDOMConvertNumbers.cpp`.
No binding uses them, but `src/codegen/bindgen.ts` maps `t.i8`, `t.i16`
and `t.i64` to them.
- `src/js/bun/sql.ts`: the export properties `sql`, `Query`, `postgres`
and the four error classes. Native code reads only `default` and `SQL`.
It is not certain that no loader path exposes the module object.
- `us_nq_settings_set_scid_len` and `us_nq_settings_set_delay_onclose`
(`node_quic_shim.c`, declared in `src/lsquic_sys/lib.rs`): no caller.
`node:quic` is under active work.
- `Event::currentTargetIsInShadowTree()` and its bit: no reader. The
lines sit next to a hunk of #39929.
- Bake client: `WebSocketWrapper.close()` and `[Symbol.dispose]()`,
`streamingStarted`, the `line` and `column` bookkeeping and seven enum
members in `JavaScriptSyntaxHighlighter.ts`, and `externals` in
`src/node-fallbacks/build-fallbacks.ts`. Each sits next to a hunk of
#43378, #40492, #40122 or #41385.
- The `internal: true` property option of the class generator. A guard
throws on it, so the branches behind it cannot run. Five open pull
requests touch `generate-classes.ts`.
- `H2App::getNativeHandle` (next to a hunk of #41195) and
`uws_app_listen_config_t` (its last user goes with #42431).
- `UWS_ALLOW_SHARED_AND_DEDICATED_COMPRESSOR_MIX`,
`UWS_ALLOW_8_WINDOW_BITS` and `LIBUS_NO_SSL`: never defined, but they
are documented opt-in switches of the upstream libraries.
- `scripts/debug-coredump.ts`, `scripts/gamble.ts`,
`scripts/github-metrics.ts`, `scripts/lldb-inline.sh` with
`scripts/lldb-inline-tool.cpp`, and `packages/h3blast`: nothing
references them. They read as tools that a person runs by hand.
- #40232 removes `napi_internal_get_version`. #42556 renamed that
function to `Bun__napi_get_version` on main, and it still has no caller.

</details>
alii pushed a commit that referenced this pull request Oct 18, 2026
…ent.cpp (#45764)

### Problem
- 29 lines in 6 files have no user.
- `source_file`, `compare_types` and `symbol_to_string` in the
`queries!` list of `src/lint/types/mod.rs` have no caller. The list
generates the only call of the `Services` functions of the same names in
`bun_sema`. The trait is `pub`, so rustc does not check it.
- `BunProcess.cpp` declares five `using X = JSC::X;` aliases that it
never names. `DirEntType` in `NodeDirent.cpp` has three enumerators that
nothing names.

### Fix
- Delete the three list lines with their `Services` functions (21
lines), the five aliases and the three enumerators.
- Correct because a word search over the sources, the tests and the
generated code finds no user, and the workspace compiles for 12 targets.
- Verified: `bun bd`, `bun run rust:check-all`, `cargo check --workspace
--all-targets`, 8 test files (Notes).
- Self-reviewed: 41 concerns raised, 33 addressed. Rejected: a
`pub(crate)` narrowing of `Queries` (`resolve_name` needs a caller
first), and a hold until earlier sweeps merge.

### Background
- `queries!` lists each question that a lint handle (`Type`, `TsSymbol`)
can ask the type checker. One line generates a `Queries` method and a
forwarding call to `Services` in `bun_sema`.
- `BunProcess.cpp` compiles as its own unit with `using namespace JSC;`,
so the aliases change no name lookup.
- A deletion of unreferenced code has one possible place, so no other
design was weighed.

### Downsides
- A later lint handle that needs one of the three queries must restore
it.
- None found for users. Checked: the heads of all 5,559 open pull
requests, 12 targets, the tests in Notes.

Behaviour change: none
<details><summary>Notes</summary>

**Removed**
- `src/lint/types/mod.rs`: the `queries!` lines `source_file`,
`compare_types` and `symbol_to_string`. No call of these names has a
`Queries` receiver. The calls that exist go to other functions:
`Checker::compare_types` and `Checker::symbol_to_string` in `bun_sema`,
a private `compare_types` in `prefer_optional_chain.rs`, and the
parser's `source_file`. With `Queries` made crate-private in a scratch
edit, rustc reports `resolve_name` as the only query left that is never
used.
- `src/sema/check/services.rs`, `services/types.rs`,
`services/symbols.rs`: `Services::source_file`,
`Services::compare_types`, `Services::symbol_to_string`. The generated
forwarding call was the only user. What they call (`Files::by_path`,
`Checker::compare_types`, `Checker::symbol_to_string`,
`Checker::prop_to_string`) keeps other callers.
- `src/jsc/bindings/BunProcess.cpp`: the aliases `Exception`,
`JSModuleLoader`, `JSModuleRecord`, `SourceOrigin`, `JSNonFinalObject`.
None of the names appears in the rest of the file. The same block in
`Path.cpp` and `ZigGlobalObject.cpp` is left to #43378 and #42431.
- `src/jsc/bindings/NodeDirent.cpp`: the enumerators `Whiteout`, `Door`
and `EventPort` of `DirEntType`, all equal to `Unknown`. No C or C++
file names them.

**Open pull requests**
- Compared at 2026-10-17 16:40 UTC on main 017b243 with the heads of
all 5,559 open pull requests, drafts and every author included.
- 156 of them touch a file of this diff (151 touch `BunProcess.cpp`). A
trial merge of each with main and with this branch (`git merge-tree`)
shows that the branch adds a conflict to none.
- None deletes one of these lines. None adds a use of a removed name:
the added lines were searched for the three query names, the five alias
names in `BunProcess.cpp`, and the three enumerators.

**Found dead in this run, and left alone**
- Already gone on main: three lines in `JSSQLStatement.cpp` and
`NodeSqlite.cpp` (#45304).
- Another open pull request deletes or rewrites them: 13 commented-out
lines in uSockets, uWS, `JSEventTargetCustom.cpp` and
`src/node-fallbacks/url.js` (#45709, and #43730 for `url.js`), two
typedefs in `InspectorHTTPServerAgent.cpp` (#45725), the
`BUN_WEBKIT_VERSION` fallback in `BunProcess.cpp` (#41729), a
commented-out line in `src/js/internal/html.ts` (#45682).
- An open pull request uses them: `Event::currentTargetIsInShadowTree()`
and the `MediaTime` overload of `JSConverter<IDLUnrestrictedDouble>`
(#45415).
- Held by an earlier sweep for a reason that still holds: the QUIC
setters `scid_len` and `delay_onclose` (#43976, and #40220 changes the
line above them).
- `resolve_name`, the fourth query with no caller. tsgolint's
`prefer-readonly` calls `ResolveName` and Bun's port does not, which
gives a wrong autofix for a global enum. The fix is handed off and needs
the query. After it, `Queries` can become `pub(crate)`, and rustc then
guards the list.
- Mirrors of typescript-eslint and tsgolint: the write-only fields
`ThenCall::on_fulfilled`, `FinallyCall::on_finally`,
`BaseTypeOfClassMember::base_type` and `heritage_token`,
`TargetElement::is_shorthand`, with `TsNode::token` (as #45402 held
them). Also 33 functions from macro lists in `src/lint/types/` that
nothing calls, and `File::expr_tags_in_tree`.
- Debugging aids: 25 hand-written `Debug` impls in `bun_lint`, 5 in
`bun_format`, and `Display` for `Difference`, `FilePoll` and `Part`.
- Handed off: the plugin `target` value that nothing reads
(`BundlerPlugin::target`, three more members, a parameter of
`JSBundlerPlugin__create`, and the Rust enum). Its removal changes an
FFI signature.
- Needs a decision: `PerformanceResourceTiming` cannot be constructed,
so `ResourceTiming.cpp`, `NetworkLoadMetrics.cpp` and `ServerTiming.h`
are reachable only from its getters.

**How the candidates were found**
- Ten text searches, one for each area: `src/js`, the C++ bindings
(three parts), uSockets and uWS, the build scripts, the side packages,
the three new crates, and commented-out code.
- A relink of the debug build with `-Wl,--gc-sections`, with each
dropped function mapped to its source line by `llvm-nm -l`: 517 C++
functions and 607 Rust function lines. Almost all are Windows or macOS
code, release-only code, or are deleted by an open pull request.
- For `bun_sema`: `pub` narrowed to `pub(crate)` on each item that no
other crate names, in a scratch tree. rustc reported nothing new.
- For 39 trait impls that the linker drops: delete all, compile for
linux, windows and darwin and with `--all-targets`, put back each impl
that an error names. What stayed deleted is a debugging aid.

**Tests, debug build of this branch** (with `--timeout 600000`, because
the lint and check tests need more than the default with a debug build)
- `test/cli/lint/conformance.test.ts`: 3 pass.
- `test/cli/lint/rules.test.ts`: 16 pass.
- `test/cli/lint/native-rules.test.ts`: 166 pass.
- `test/cli/lint/bun-rules.test.ts`: 100 pass.
- `test/cli/check/check.test.ts`: 599 pass, 42 skip.
- `test/js/node/process/process.test.js`: 188 pass, 5 skip.
- `test/js/node/fs/dir.test.ts`: 23 pass.
- `test/regression/issue/24129.test.ts`: 2 pass.

</details>

<!-- robobun:evidence:begin -->

---

**no test proof** · iteration 0 · the description declares no behaviour
change, so there is no failing test to prove; the existing suite in CI
is the check

<!-- robobun:evidence:end -->
The branch was 588 commits behind main. Every deletion was checked again
against the merged tree.

Dropped, because main uses the code again:
- us_quic_socket_close (quic.c, quic.h): src/uws_sys/quic/Socket.rs
  imports it since #42692.
- The sqlite3_errcode entry of lazy_sqlite3.h: JSSQLStatement.cpp calls
  it since #45304. The header is only compiled on macOS, so the other
  three entries stay too. A Linux build cannot check them.

Dropped, because main changed or removed the code:
- scripts/azure.mjs, scripts/machine.mjs, scripts/runner.node.mjs,
  CommonJS.ts, ProcessObjectInternals.ts, sql.ts, BunPlugin.cpp,
  BakeAdditionsToGlobalObject.h, JSBakeResponse.cpp, uws_app_listen,
  the lazyLoadSQLite stubs, and the _flags parameter in net.ts.

Dropped, to keep the change free of any behavior difference:
- SecretsLinux.cpp keeps the six pointers that load_functions() tests.
  Only the nine pointers that nothing reads are removed.
- child_process.ts keeps the debug-only globalThis.__getId.
The comment named w::ntdll::NtClose. bun_windows_sys::ntdll no longer
declares it.
@robobun robobun changed the title Remove dead code from the WebCore, node, and sqlite bindings, uWS/uSockets, SecretsLinux, and five Rust crates Remove dead code from the JSC, WebCore, and node bindings, uWS/uSockets, SecretsLinux, and seven Rust crates Oct 23, 2026

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

I re-reviewed this after the merge of main and did not find any bugs, but with 106 files touched (including crypto, secrets, and Windows-only code that only CI can type-check) and a CODEOWNER-covered .d.ts in the diff, a human look is still worthwhile.

What was reviewed:

  • Windows-gated removals (NtClose, IsProcessInJob, GetSystemInfo/SYSTEM_INFO, JOBOBJECT_ASSOCIATE_COMPLETION_PORT): every remaining caller uses a local safe fn extern block in src/sys/windows/mod.rs, src/bun_alloc/lib.rs, and the windows-shim, not the deleted crate-root exports.
  • Link-interface hooks (ErrnoNames::win32_name, JsEventLoop::{file_polls,put_file_poll,stdout,stderr}) and FFI symbols (us_socket_pair, us_socket_open, us_listen_socket_get_fd, uws_app_run, non-Linux preadv2/pwritev2 stubs): no dispatcher callers or extern declarations remain in src/ or packages/.
  • C++ shape changes: JSNodeHTTPServerSocketPrototype::createStructure is bypassed by a direct Structure::create in JSNodeHTTPServerSocket.cpp; CryptoAlgorithmRsaKeyGenParams is only a base class with the base's Class::None default and nothing downcasts to it; all ByteSource consumers call .span()/.data()/.size() explicitly, so the removed implicit Buffer conversion had no users.
  • Removed includes and extern "C" lines each leave a duplicate in the same file; the #ifndef __cplusplus branches in headers-handwritten.h sit below C++ includes and a namespace, so were never reachable.
Extended reasoning...

The PR is a 106-file, +5/-736 dead-code sweep across the C++ JSC/WebCore bindings, uWS/uSockets, the JS builtins, and several Rust crates, re-based on a 588-commit merge of main that dropped the deletions main had made stale. It touches crypto and secrets headers (ncrypto.h, KeyObject.h, CryptoUtil.h, webcrypto, SecretsLinux.cpp) only by removing unused enum variants, accessors, and dlsym loads, and does not change any TLS or crypto behavior. Each removal category was grep-verified against the merged tree, including the Windows-only and link-interface items that rustc cannot lint, and nothing was found still referencing a deleted symbol. Deferring rather than approving because the diff is large, cfg-gated macOS/Windows code cannot be type-checked on this host, src/js/builtins.d.ts falls under the *.d.ts CODEOWNERS entry, and the PR changed substantively since the prior review.

This branch has not been deployed

No deployments
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