Remove dead code from the streams bindings, node:http, bun_sys, lsquic_sys, and orphaned files

Merged
RO
3mo ago
+10-2736

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 c4a937c53d, 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.

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

fails on main (without fix)
ASAN without fix: 3 FAILED
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts
bun test v1.4.0 (59bf369d3)

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 (da3851e57)

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)
passes on PR (with fix)
ASAN with fix: all passed
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/dead-symbols-streams-http-misctools.test.ts
bun test v1.4.0 (59bf369d3)

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)

   Compiling bun_core v0.0.0 (/workspace/bun/src/bun_core)
   Compiling bun_errno v0.0.0 (/workspace/bun/src/errno)
   Compiling bun_ptr v0.0.0 (/workspace/bun/src/ptr)
   Compiling bun_boringssl_sys v0.0.0 (/workspace/bun/src
... (truncated)
diff hotspot
.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)

gate history · 1 passed · 1 rejected · iteration 1

evidence per changed file
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)