Repository navigation
Remove dead code from the JSC FFI bindings, the uws HTTP/2 glue, and misc sources - #40881
Conversation
…misc sources Delete 21 extern "C" functions in bindings.cpp (and their headers.h declarations) that no Rust code calls: JSC__JSValue__isInt32 and the other JSValue predicates the Rust side implements inline, JSC__JSMap__has, JSC__JSPromise__isHandled, JSC__JSInternalPromise__reject/resolve, JSC__JSValue__jsNumberFromChar/U16, jsTDZValue, jsType, JSC__VM__isJITEnabled, isTerminationException, and performOpportunisticallyScheduledTasks. Delete seven uws_h2_res_* C shims in libuwsockets_h2.cpp that have no Rust declaration, plus the one Rust wrapper (Response::override_write_offset) nothing calls. Drop an unreferenced macro in JSSQLStatement.cpp, the unreachable #else branches of two #if 1 blocks in CryptoAlgorithmRSA_PSSOpenSSL.cpp, and the unexported SlowBuffer helper in the browser buffer fallback.
|
Updated 11:35 PM PT - Aug 28th, 2026
❌ @robobun, your commit 37b0212 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 40881That installs a local version of the PR into your bun-40881 --bun |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
💤 Files with no reviewable changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. WalkthroughChangesThe pull request removes obsolete JavaScriptCore and HTTP/2 bindings, simplifies RSA-PSS signing and verification, removes a SQLite compatibility macro, deletes the Node Binding and runtime cleanup
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change removes unused native bindings and unreachable code without changing intended runtime behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Full details: Description checkExplanation The description provides detailed problem, fix, background, verification steps, test coverage, and implementation notes. It does not use the template headings exactly, but it contains the required information and is complete. Comment |
There was a problem hiding this comment.
LGTM — pure dead-code removal with no behavior change.
Grepped every deleted symbol (JSC__JSValue__is*/jsType/jsNumberFromChar/jsNumberFromU16/jsTDZValue, JSC__JSPromise__isHandled, JSC__JSInternalPromise__reject/resolve, JSC__VM__isJITEnabled/isTerminationException/performOpportunisticallyScheduledTasks, JSC__JSMap__has, uws_h2_res_{get_write_offset,override_write_offset,prepare_for_sendfile,get_native_handle,get_socket_data,uncork,is_corked}, override_write_offset) across the tree — zero remaining references. headers.h prototypes and the Rust extern were removed in lockstep with the .cpp definitions; the few [[ZIG_EXPORT]]-only ones (isCell, isNull, isUndefined, isUndefinedOrNull) never had a headers.h decl to begin with. SlowBuffer in the browser fallback was never exported; the #if 1 unwrap in RSA-PSS and the BREAKING_CHANGES_BUN_1_2 macro removal are trivially no-ops (the test/harness.ts constant of the same name is unrelated JS).
Extended reasoning...
Overview
This PR deletes ~150 lines of unreferenced code across eight files: 21 C++ FFI shim functions in src/jsc/bindings/bindings.cpp with their matching CPP_DECL prototypes in headers.h, seven uws_h2_res_* C wrappers in src/uws_sys/libuwsockets_h2.cpp plus the one Rust extern and Response::override_write_offset wrapper in src/uws_sys/h2.rs, an unused BREAKING_CHANGES_BUN_1_2 macro in JSSQLStatement.cpp, two always-true #if 1 guards in CryptoAlgorithmRSA_PSSOpenSSL.cpp, the never-exported SlowBuffer helper in src/node-fallbacks/buffer.js, and a doc-comment reword in src/jsc/JSValue.rs that drops a stale bindings.cpp:2755 line reference. Only three lines are added, all in the reworded comment.
Security risks
None. Nothing added is executable; every hunk is a deletion of code that had no reachable caller, or an unwrap of an #if 1 that leaves the compiled output byte-identical. The RSA-PSS change keeps the exact same sign/verify body that was already active. No auth, permission, or input-validation path is touched.
Level of scrutiny
Low-to-medium — the only real risk in a dead-code PR is deleting something that still has a caller hidden behind codegen, a #[cfg] gate, or an external linker reference. I grepped the full tree for every removed symbol name and found zero hits outside the deleted lines themselves; the headers.h declarations were removed in the same commit as their definitions, and the [[ZIG_EXPORT]]-only functions that lacked a headers.h entry (isCell, isNull, isUndefined, isUndefinedOrNull) are confirmed absent from headers.h on HEAD. The PR description documents nm --undefined-only checks against the prebuilt WebKit libraries and bun run rust:check-all across all 12 targets, which covers the platform-gated-code concern.
Other factors
REVIEW.md explicitly requires deleting dead code in the PR that makes it dead and updating every consumer atomically — this change does exactly that (definition + header prototype + Rust extern removed together). No CODEOWNERS pattern matches the changed files. The bug-hunt exit reason was dry_streak with no findings and no ruled-out candidates. The one remaining SlowBuffer string in src/node-fallbacks/buffer.js is inside a comment, and the BREAKING_CHANGES_BUN_1_2 constant in test/harness.ts is an unrelated TypeScript export. The PR notes adjacent-hunk overlap with two other open PRs, but the deletions are disjoint and any conflict is a trivial rebase.
Problem
JSValue::is_int32,is_null,is_object,js_type, and friends inline (src/jsc/JSValue.rs), but the[[ZIG_EXPORT]]/CPP_DECLfunctions they replaced stayed insrc/jsc/bindings/bindings.cppandheaders.h, andcppbind.tsstill emitted Rust wrappers for them.src/uws_sys/libuwsockets_h2.cppdefines sevenuws_h2_res_*C shims with no Rust declaration, and one (uws_h2_res_override_write_offset) whose only Rust wrapper nothing calls.Fix
bindings.cppand their 15headers.hdeclarations:JSC__JSValue__{isCell, isCustomGetterSetter, isGetterSetter, isInt32, isInt32AsAnyInt, isNull, isNumber, isObject, isUndefined, isUndefinedOrNull, jsNumberFromChar, jsNumberFromU16, jsTDZValue, jsType},JSC__JSMap__has,JSC__JSPromise__isHandled,JSC__JSInternalPromise__{reject, resolve},JSC__VM__{isJITEnabled, isTerminationException, performOpportunisticallyScheduledTasks}.uws_h2_res_{override_write_offset, get_write_offset, prepare_for_sendfile, get_native_handle, get_socket_data, uncork, is_corked}andResponse::override_write_offsetinsrc/uws_sys/h2.rs.BREAKING_CHANGES_BUN_1_2macro inJSSQLStatement.cpp, the unreachable#elsebranches of two#if 1blocks inCryptoAlgorithmRSA_PSSOpenSSL.cpp, and the never-exportedSlowBufferinsrc/node-fallbacks/buffer.js.src/**,packages/**,build/debug/codegen/**, and the prebuilt WebKit libraries.bun bdlinks,bun run rust:check-allpasses on all 12 targets. Ranserve.test.ts,serve-http2.test.ts,serve-http2-protocol.test.ts,sqlite.test.js,web-crypto.test.ts,buffer.test.js,bundler_browser.test.ts.test/internal/source-lints/CLAUDE.mdasks for no dead-symbol lint tests.Background
[[ZIG_EXPORT(mode)]]marks a C++ function thatsrc/codegen/cppbind.tsscrapes intobuild/*/codegen/cpp.rsas a Rustextern "C"declaration plus a safe wrapper. Rust calls the wrapper asbun_jsc::cpp::Name. A function with no Rust caller is unreachable: C++ never calls these shims directly.headers.hcarries hand-writtenCPP_DECLprototypes for the same extern "C" surface. Both sides were trimmed together.Bun__*symbols and define two weak defaults that Bun overrides (Bun__thisThreadHasVM,Bun__analyzeTranspiledModule). None of the deleted symbols is in either set.Notes
How the candidates were found:
pubRust item with zero textual references outside its crate was rewritten topub(crate), thencargo check -p <crate>was run withdead_codeas a warning, on linux, windows, and darwin targets. Items flagged on all three targets and not referenced from macro bodies ($crate::) were the Rust candidates. After excluding files and symbols that the 13 open dead-code PRs already remove, the only survivor wasResponse::override_write_offset. The workspace already compiles withdead_code = "deny"andunreachable_pub = "deny", so private dead code cannot exist.nm --defined-onlyover every object inbuild/debug/objandlibbun_runtime.a, minusnm --undefined-onlyover all objects and the WebKit libraries (libWTF.a,libJavaScriptCore.a,libbmalloc.a, including their weak symbols), gave the set of C-linkage symbols nothing references at link time. A test link with--gc-sections --print-gc-sections(without-rdynamic) confirmed the same set. Codegen-emitted symbols (*__fromJS,*GetCachedValue, JSSink*__createObject) were excluded because they are regenerated from.classes.ts.-fsyntax-only -Wunused-function -Wunused-template -Wunused-member-function. The 14 warnings were either in files open PRs already edit or header templates used by other translation units.src/js/**andsrc/node-fallbacks/**were checked export by export.oxlintalready enforcesno-unused-varsthere, and all 235 bundled files and everyinternal/*export have consumers.Not touched on purpose:
Bun__thisThreadHasVMlooks unreferenced but WebKit'sRunLoopBun.cppdeclares it weak and asserts in its fallback. Removing it aborts every run.src/jsc/bindings/webcrypto/*.idl(29 files) have no consumer, but the webcore.idlfiles are kept the same way as reference for the hand-written bindings.src/runtime/webview/ObjCRuntime.{h,cpp}:NSObject::describeandWKWebView::isLoadinghave no callers, but the file compiles only on macOS.bindings.cppandheaders.hare also edited by Remove dead code from the JSC bindings, headers.h, the console builtin, and bun_jsc #40232 and Remove dead code from bun_jsc, bun_runtime, bun_core, and the JSC bindings #40824. The deleted functions are disjoint from both, but hunks are adjacent, so whichever merges second needs a trivial rebase.