Skip to content

Remove dead code from uws_sys, webcore bindings, crash_handler, and scripts - #37181

Open
robobun wants to merge 12 commits into
mainfrom
claude/farm/024726b1/dead-code-uws-webcore-semver-scripts
Open

Remove dead code from uws_sys, webcore bindings, crash_handler, and scripts#37181
robobun wants to merge 12 commits into
mainfrom
claude/farm/024726b1/dead-code-uws-webcore-semver-scripts

Conversation

@robobun

@robobun robobun commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Dead code sweep: net -2,382 lines across 38 files. Every removal was verified to have zero references across src/, vendor/, scripts/, test/, and regenerated build/debug/codegen output before deletion.

uws_sys (-470)

  • libuwsockets.cpp: 24 unused C API wrappers (uws_ws_send, uws_ws_publish, uws_app_listen_domain, uws_add_server_name, uws_remove_server_name, uws_missing_server_name, uws_constructor_failed, uws_get_native_handle, uws_ws_send_fragment, uws_ws_send_first_fragment, uws_ws_send_first_fragment_with_opcode, uws_ws_send_last_fragment, uws_ws_get_remote_address_as_text, uws_res_get_write_offset, uws_res_override_write_offset, uws_res_get_socket_data, uws_req_is_ancient, uws_req_get_yield, uws_req_for_each_header, uws_req_get_query, uws_loop_addPostHandler, uws_loop_removePostHandler, uws_loop_addPreHandler, uws_loop_removePreHandler). The *_with_options variants are the live paths and stay.
  • libuwsockets_h3.cpp: 14 equivalent uws_h3_* wrappers nothing declares or calls.
  • _libusockets.h: uws_missing_server_handler and uws_get_headers_server_handler typedefs, used only by deleted wrappers.
  • Rust side: the orphaned extern declarations plus unused wrappers Response/h3 override_write_offset, Loop add_pre_handler and add_post_handler (both platforms, including the Handler struct and LoopCtxCb alias only they used), SocketTCP::from_named_pipe (Windows callers use their own helpers in WindowsNamedPipeContext), us_fault_clear, LIBUS_LISTEN_DISALLOW_REUSE_PORT_FAILURE.

C++ bindings (-860)

  • webcore/DOMConstructors.h: trimmed the DOMConstructorID enum from 849 entries to the 51 bun actually references (the rest were WebKit-inherited Touch/ApplePay/WebGL/MediaKeys etc.). Also shrinks the per-GlobalObject constructor WriteBarrier array from 849 to 51 slots. No code casts the enum numerically and nothing reads the old count constants.
  • napi.h NAPI_PERISH macro, dh-primes.h OPENSSL_ARRAY_SIZE and TOBN macros (scaffolding for prime tables the header no longer contains), JSDOMWrapper.h hasCustomPtrTraits (upstream WebKit uses it, bun's copy does not), forward declarations JSPerformanceObject / Wasm::MemoryHandle / FragmentedSharedBuffer, commented-out KeyObject::createJwk declaration.

crash_handler (-270)

  • The error-return-trace apparatus: cold_handle_error_return_trace, handle_error_return_trace_extra, VERBOSE_ERROR_TRACE, HAVE_ERROR_RETURN_TRACING. Rust has no error return traces, so the whole path sat behind a const false (the code itself said so). Removing it also removes the always-None error_return_trace parameters of handle_root_error and panic_impl (plus the unreachable TraceSeed::ErrorReturn variant), the show_trace local whose branches had become indistinguishable, and the no-op --verbose-error-trace debug-build flag that only stored into the dead static.
  • The unused Display impl for StackLine (the symbolizer formats the address field directly).
  • The HandleOom trait: its Error/AllocError arms had no instantiations, and with one impl left the trait itself was ceremony. handle_oom is now a plain function over Result<T, AllocError>, matching its only caller (js_parser scan_imports).

Misc Rust (-20)

  • collections: Default impl for PriorityQueue (all construction goes through ::init).

Scripts and assets (-1,170)

  • scripts/clippy-loop/ (984 lines, 12 files): one-shot tooling for the clippy campaign completed in clippy: 33 deny lints + fix 2735 violations across workspace #31116 (2026-05); zero invokers in repo, package.json, .buildkite, or .github, and it hardcodes a machine path that no longer exists.
  • src/base64/neonbase64: orphan 17.6 KB LLVM bitcode blob with zero build-system references.
  • src/js/bun/sql.ts: commented-out $createPostgresError/$createSQLiteError/$createSQLError helpers native code never called.

Verification

  • cargo check passes on all 10 CI target triples (bun run rust:check-all), which also arbitrated the sweep: an earlier candidate (the semver formatter chain) turned out to be live via install's lockfile debug stringify and was restored, not deleted.
  • Full bun bd debug build passes; smoke ran websocket-server.test.ts (publish/send paths over the uws glue), node-stream.test.js, a bun:sqlite round trip, and a constructor smoke over the trimmed DOMConstructors set (TextEncoder, URLPattern, CookieMap, streams, MessageChannel, structuredClone).
  • test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts pins the removed symbols against reintroduction, following the existing dead-symbols lints.

Noted but deliberately not removed (for a future pass)

  • JSBufferList.cpp/.h and its ZigGlobalObject wiring (~640 lines): dead since the JS streams implementation replaced native BufferList (Replace Streams.Readable with a JS implementation #11332), but the whole-file removal is coupled to its global-object accessors and IsoSubspace slots across shared headers, so it needs its own PR.
  • webcore/EventInterfaces.h: ~100 lines of ENABLE()-gated entries look removable but cascade into WebKit-imported switch code.
  • webcore/JSDOMConvertNull.h: IDLNull has no concrete instantiation, but JSDOMConvertUnion mentions it in template machinery.
  • MimallocWTFMalloc.h zeroedMalloc/tryZeroedMalloc/nextCapacity: zero refs in repo, but WTF malloc-policy templates duck-type these members.
  • scripts/lldb-inline*, find-dead-exports.ts, github-metrics.ts, gamble.ts: zero in-repo invokers but plausibly still used by hand.

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

fails on main (without fix)
ASAN without fix: 1 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-uws-webcore-crash-scripts.test.ts
bun test v1.4.0 (33d3ab446)

test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts:
80 |     ["src/runtime/cli/Arguments.rs", /verbose-error-trace|maybe_verbose_error_trace/],
81 |     // All PriorityQueue construction goes through ::init.
82 |     ["src/collections/lib.rs", /impl<T, C: Default> Default for PriorityQueue/],
83 |   ];
84 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
85 |   expect(resurrected).toEqual([]);
                           ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/uws_sys/WebSocket.rs: uws_ws_send_fragment|uws_ws_send_first_fragment|uws_ws_get_remote_address_as_text",
+   "src/uws_sys/Response.rs: override_write_offset",
+   "src/uws_sys/h3.rs: override_write_offset",
+   "src/uws_sys/Loop.rs: add_pre_handler|add_post_handler|uws_loop_addPreHandler|uws_loop_addPostHandler",
+   "src/uws_sys/socket.rs: \bfrom_named_pipe\b",
+ 
... (truncated)

release without fix: 1 FAILED
bun test v1.4.0-canary.1 (ed3b524b4)

test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts:
80 |     ["src/runtime/cli/Arguments.rs", /verbose-error-trace|maybe_verbose_error_trace/],
81 |     // All PriorityQueue construction goes through ::init.
82 |     ["src/collections/lib.rs", /impl<T, C: Default> Default for PriorityQueue/],
83 |   ];
84 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
85 |   expect(resurrected).toEqual([]);
                           ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/uws_sys/WebSocket.rs: uws_ws_send_fragment|uws_ws_send_first_fragment|uws_ws_get_remote_address_as_text",
+   "src/uws_sys/Response.rs: override_write_offset",
+   "src/uws_sys/h3.rs: override_write_offset",
+   "src/uws_sys/Loop.rs: add_pre_handler|add_post_handler|uws_loop_addPreHandler|uws_loop_addPostHandler",
+   "src/uws_sys/socket.rs: \bfrom_named_pipe\b",
+   "src/uws_sys/lib.rs: us_fault_clear\b|LIBUS_LISTEN_DISALLOW_REUSE_PORT_FAILURE",
+   "src/crash_handler/lib.rs: error_return_trace|VERBOSE_ERROR_TRACE|HAVE_ERROR_RETURN_TRACING|TraceSeed::ErrorRet
... (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-uws-webcore-crash-scripts.test.ts
bun test v1.4.0 (33d3ab446)

test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts:
(pass) dead Rust symbols (uws_sys, crash_handler, collections) do not reappear [30.34ms]
(pass) dead uws_sys C wrappers do not reappear [32.76ms]
(pass) dead C++ bindings do not reappear [40.67ms]
(pass) deleted files stay deleted [13.95ms]

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

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 671ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/127] gen generated_host_exports.rs
generated_host_exports.rs: 92 exports (host=3, lazy=10, generic=79, rust=0); 239 extern-C blocks audited
[2/127] gen cpp.rs (cppbind)
[3/127] gen JS modules (bundle-modules)
Preprocess modules (9069ms)
Bundle modules (68ms)
Postprocesss modules (240ms)
Bundle Functions (837ms)
Generate Code (32ms)

[10.27s] Bundled "src/js" for production
  2608 kb
  197 internal modules
  13 native modules
  91 internal functions across 17 files
[3/126] 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/boringssl_sys)
�[1m�[92m   Compiling�[0m bun_safety v0.0.0 (/workspace/bun/src/safety)
�[1
... (truncated)
diff hotspot
scripts/clippy-loop/apply-patches.ts               |  57 --
 scripts/clippy-loop/collect-all-targets.sh         |  88 ---
 scripts/clippy-loop/collect-pr-comments.sh         |  52 --
 scripts/clippy-loop/collect.sh                     |  26 -
 scripts/clippy-loop/de-unsafe.workflow.ts          | 107 ---
 scripts/clippy-loop/edit-round.workflow.ts         | 119 ---
 scripts/clippy-loop/fix-round.workflow.ts          | 158 ----
 scripts/clippy-loop/group-by-file.ts               | 132 ----
 scripts/clippy-loop/harvest.ts                     |  90 ---
 scripts/clippy-loop/review-round.workflow.ts       |  94 ---
 scripts/clippy-loop/shard.ts                       |  30 -
 scripts/clippy-loop/split-diags.ts                 |  31 -
 src/base64/neonbase64                              | Bin 17648 -> 0 bytes
 src/bun_core/lib.rs                                |  20 +-
 src/collections/lib.rs                             |   8 -
 src/crash_handler/handle_oom.rs                    |  93 +--
 src/crash_handler/lib.rs                           | 142 +---
 src/js/bun/sql.ts                                  |  28 -
 src/jsc/bindings/JSDOMWrapper.h                    |   1 -
 src/jsc/bindings/dh-primes.h                       |  12 -
 src/jsc/bindings/napi.h                            |   7 -
 src/jsc/bindings/node/crypto/KeyObject.h           |   1 -
 src/jsc/bindings/webcore/DOMConstructors.h         | 859 +--------------------
 src/jsc/bindings/webcore/JSPerformance.h           |   2 -
 src/jsc/bindings/webcore/SerializedScriptValue.h   |   2 -
 src/runtime/api/crash_handler_jsc.rs               |   4 +-
 src/runtime/cli/Arguments.rs                       |  21 -
 src/runtime/cli/mod.rs                             |   2 +-
 src/uws_sys/Loop.rs                                |  77 --
 src/uws_sys/Response.rs                            |  13 -
 src/uws_sys/WebSocket.rs                           |  27 -
 src/uws_sys/_libusockets.h                         |   7 -
 sr
... (truncated)

gate history · 4 passed · 2 rejected · iteration 4

evidence per changed file
file                                          reads  edits  tests
scripts/clippy-loop/apply-patches.ts              0      0      0
scripts/clippy-loop/collect-all-targets.sh        0      0      0
scripts/clippy-loop/collect-pr-comments.sh        0      0      0
scripts/clippy-loop/collect.sh                    0      0      0
scripts/clippy-loop/de-unsafe.workflow.ts         0      0      0
scripts/clippy-loop/edit-round.workflow.ts        0      0      0
scripts/clippy-loop/fix-round.workflow.ts         0      0      0
scripts/clippy-loop/group-by-file.ts              0      0      0
scripts/clippy-loop/harvest.ts                    0      0      0
scripts/clippy-loop/review-round.workflow.ts      0      0      0
scripts/clippy-loop/shard.ts                      0      0      0
scripts/clippy-loop/split-diags.ts                0      0      0
src/base64/neonbase64                             0      0      0
src/bun_core/lib.rs                               2      4      0
src/collections/lib.rs                            1      2      0
src/crash_handler/handle_oom.rs                   2      3      0
(+ 22 more files)

…ctions, and scripts

uws_sys: 23 unused C API wrappers in libuwsockets.cpp, 14 in
libuwsockets_h3.cpp, their orphaned Rust extern declarations and safe
wrappers (override_write_offset, add_pre_handler, from_named_pipe), and
two handler typedefs only the deleted wrappers used.

webcore/jsc bindings: JSBufferList (native BufferList superseded by the
JS streams implementation; its lazy class structure had zero reachable
accessors), ~800 WebKit-inherited DOMConstructorID enum entries bun
never wires (also shrinks the per-GlobalObject constructor array from
849 to 51 slots), NAPI_PERISH, OPENSSL_ARRAY_SIZE, hasCustomPtrTraits,
and stray forward declarations.

crash_handler: the error-return-trace apparatus (unreachable behind
const false HAVE_ERROR_RETURN_TRACING since Rust has no error return
traces), the no-op --verbose-error-trace debug flag that fed it, the
unused StackLine Display impl, and HandleOom impls nothing instantiates.

collections: unused Default impl for PriorityQueue.

scripts: clippy-loop/ one-shot campaign tooling (campaign completed
2026-05, zero in-repo invokers), orphan LLVM bitcode blob
src/base64/neonbase64, commented-out $create*Error helpers in bun/sql.ts.

Verified by rg across src/, vendor/, scripts/, and regenerated codegen
output; cargo check on all 10 CI target triples; full debug build; and
a source lint pinning the removed symbols.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The change deletes retired Clippy automation, simplifies crash and OOM handling, removes obsolete JSC/WebCore declarations, prunes unsupported uWS interfaces, and adds source-lint checks for deleted symbols and files.

Changes

Dead code and API cleanup

Layer / File(s) Summary
Simplify crash and OOM handling
src/crash_handler/*, src/bun_core/lib.rs, src/runtime/api/crash_handler_jsc.rs, src/runtime/cli/*
handle_oom now accepts Result<T, AllocError>. Root-error handling no longer accepts error-return traces. Verbose trace state, helpers, CLI parsing, callers, and related documentation are removed or updated.
Remove obsolete JSC and WebCore bindings
src/jsc/bindings/*, src/js/bun/sql.ts
The DOM constructor set is reduced to retained entries. Unused declarations, macros, and commented helpers are removed.
Prune unsupported uWS interfaces
src/uws_sys/*
Obsolete loop handlers, response offset APIs, WebSocket operations, request helpers, HTTP/3 wrappers, C declarations, and socket constructors are removed.
Validate removed symbols and tooling
test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts
Source-lint checks verify that removed symbols and deleted Clippy scripts remain absent.

Possibly related PRs

Suggested reviewers: dylan-conway, jarred-sumner

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary dead-code removals across the main affected subsystems.
Description check ✅ Passed The description explains the changes and provides detailed verification evidence, including builds, checks, and smoke tests.

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the claude label Aug 8, 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.

Beyond the inline nit, I spot-checked two areas: (1) the trimmed DOMConstructorID enum — grepped all DOMConstructorID:: references across src/jsc/bindings/ and confirmed exactly 51 usages, each mapping to a retained entry, and numberOfDOMConstructors = 51 matches the enum count; (2) show_trace in handle_root_error — still read at the if !show_trace { Global::exit(1) } guard, so removing the later assignments doesn't orphan it.

Extended reasoning...

The reported nit (orphaned m_subspaceForBufferList / m_clientSubspaceForBufferList fields) already covers the one incomplete-cleanup issue found. I additionally verified the two highest-risk removals: the DOMConstructors array-shrink (all 51 call sites accounted for, count constant matches) and the crash_handler show_trace refactor (variable still has a live reader after the mutating assignments were dropped). Given the -2.9k line scope across uws_sys FFI, ZigGlobalObject, and DOMConstructors, deferring to human review; this note is just to record what was already checked.

Comment thread src/jsc/bindings/ZigGlobalObject.h
Deleting the translation unit while its ZigGlobalObject accessors go away
in the same change does not survive a partial source-tree restore, where
the resurrected file compiles against the trimmed header. Defer the
JSBufferList removal and drop its entries from the source lint.
Comment thread src/crash_handler/handle_oom.rs Outdated
The HandleOom trait had a single remaining impl; its only caller
(js_parser scan_imports) threads Result<T, AllocError> directly.
Comment thread src/bun_core/lib.rs Outdated
Comment thread src/crash_handler/handle_oom.rs
Comment thread src/bun_core/lib.rs
@robobun

robobun commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 12:01 AM PT - Aug 8th, 2026

@robobun, your commit 33d3ab446f9d6a63e3262f6149c7caee983aadb5 passed in Build #90537! 🎉


🧪   To try this PR locally:

bunx bun-pr 37181

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

bun-37181 --bun

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • 🟡 src/crash_handler/handle_oom.rs:26-28 — Removing the Result<T, crate::Error> / bare Error / bare AllocError HandleOom impls orphans doc comments in src/bun_core/lib.rs:1012 ("The full multi-arm version (which narrows mixed error sets) lives in bun_crash_handler::handle_oom") and :1029 ("For the narrowing version see bun_crash_handler::HandleOom") — there is no longer a multi-arm or narrowing version. Since this PR already rewrote the doc in handle_oom.rs to reflect the reduced surface, the cross-referencing docs in bun_core should be updated in the same sweep.

    Extended reasoning...

    What changed vs. what the docs still claim

    This PR removes three of the four HandleOom impls from src/crash_handler/handle_oom.rs:

    • impl HandleOom for AllocError (bare error → Infallible)
    • impl<T> HandleOom for Result<T, crate::Error> (mixed error set → same union with OOM subtracted — the narrowing arm)
    • impl HandleOom for crate::Error (bare mixed error → same set with OOM subtracted)

    Only impl<T> HandleOom for Result<T, AllocError> survives. The PR correspondingly rewrote the doc comment in handle_oom.rs itself from a multi-paragraph "OOM-only vs. other errors possible" matrix explanation down to a two-line "Unwraps a Result<T, AllocError>".

    However, src/bun_core/lib.rs still has two doc comments that describe the removed behavior as if it exists in bun_crash_handler:

    • Line 1012–1016 (on bun_core::handle_oom): "The full multi-arm version (which narrows mixed error sets) lives in bun_crash_handler::handle_oom; … this tier-0 alias is the OOM-only arm — sufficient for the Result<T, AllocError> / Result<T, Error> callers". After this PR, bun_crash_handler::handle_oom is single-arm and does not narrow mixed error sets, and it no longer accepts Result<T, Error> at all.
    • Line 1029 (on UnwrapOrOom): "For the narrowing version see bun_crash_handler::HandleOom". The narrowing behavior (mixed error set → subset without OOM) was exactly the removed Result<T, crate::Error> impl.

    Line 1033–1035 ("Callers that want a strict error{OutOfMemory}-only whitelist should use bun_crash_handler::HandleOom") is arguably still accurate — the surviving impl is the strict whitelist — so only 1012 and 1029 are unambiguously stale.

    Step-by-step proof

    1. Before this PR, bun_crash_handler::HandleOom had four impls; the doc block above them described an "input-shape × OOM-only matrix" with per-arm section comments (── .error_union, isOomOnlyError == true → …, etc.).
    2. src/bun_core/lib.rs:1012 cross-references that structure: "the full multi-arm version … lives in bun_crash_handler::handle_oom", and line 1029 cross-references the narrowing arm specifically.
    3. This PR deletes those three impls and rewrites the local doc in handle_oom.rs to describe the new single-arm surface — so the PR author explicitly acknowledged the surface changed and updated the local documentation.
    4. The cross-references in bun_core/lib.rs were not updated, so they now point readers at a "multi-arm" / "narrowing" version that no longer exists.

    Why it matters here specifically

    REVIEW.md → Code style: "Delete dead code in the same PR that makes it dead." Comments describing removed functionality are stale documentation this PR itself orphaned. This PR is a dead-code sweep and already updated the doc in handle_oom.rs to reflect the reduced surface — the cross-referencing docs in bun_core are the same class of leftover as the m_subspaceForBufferList fields already flagged on this PR.

    Impact

    None on correctness — purely misleading documentation that will send a future reader looking for a "narrowing" / "multi-arm" bun_crash_handler::HandleOom that no longer exists.

    Fix

    In src/bun_core/lib.rs:

    • Rewrite the handle_oom doc (~lines 1011–1016) to drop the "full multi-arm version … lives in bun_crash_handler" sentence and the Result<T, Error> mention — both crates now expose the same single-arm behavior.
    • Drop the "For the narrowing version see bun_crash_handler::HandleOom" sentence from the UnwrapOrOom doc (~line 1029).

Comment thread src/uws_sys/Loop.rs Outdated
Comment thread src/crash_handler/lib.rs Outdated
…mnant

add_post_handler (both loop types), the Handler struct it returned, the
LoopCtxCb alias, and the uws_loop_addPostHandler extern plus C++ wrapper
had zero callers; the removal-side C++ was already deleted. In
handle_root_error the show_trace local chose between two identical
silent exit(1) paths once the trace block was gone. Also drop the stale
multi-arm handle_oom cross-references from bun_core docs.
Comment thread src/bun_core/lib.rs
The previous commit unintentionally restored the orphan bitcode blob.
@robobun

robobun commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review follow-ups in dfc555a and 96e6789: the add_post_handler chain (both loop impls, Handler, LoopCtxCb, extern declaration, C++ wrapper) is deleted, the show_trace local in handle_root_error is collapsed, and the stale multi-arm handle_oom cross-references in bun_core docs are rewritten. The source lint now pins the addPostHandler symbols as well.

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

Actionable comments posted: 3

🤖 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 `@src/jsc/bindings/webcore/DOMConstructors.h`:
- Around line 63-65: Replace the hardcoded numberOfDOMConstructors value with an
enum sentinel representing the end of the DOM constructor entries, then derive
the array size from that sentinel. Update ConstructorArray and getDOMConstructor
usage as needed so the sentinel is not treated as a valid constructor and
indexing remains bounded automatically when enum entries change.
- Around line 13-56: Add a terminal count enumerator to DOMConstructorID and
replace the independent literal 51 used for m_array’s extent with that
enumerator. Update numberOfDOMConstructors or its equivalent sizing declaration
so getDOMConstructor remains covered automatically when new constructor IDs are
added.

In `@test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts`:
- Around line 43-50: Update existsInHead to use git ls-tree instead of git
cat-file -e, treating empty stdout as a missing path and returning true when the
path is present. Check the command’s exitCode separately and throw on any
nonzero result so Git failures are never converted into a deleted-file result.
🪄 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: a6ab037d-bd4d-4a7c-bbbc-434daa986354

📥 Commits

Reviewing files that changed from the base of the PR and between f972c28 and 716209c.

📒 Files selected for processing (38)
  • scripts/clippy-loop/apply-patches.ts
  • scripts/clippy-loop/collect-all-targets.sh
  • scripts/clippy-loop/collect-pr-comments.sh
  • scripts/clippy-loop/collect.sh
  • scripts/clippy-loop/de-unsafe.workflow.ts
  • scripts/clippy-loop/edit-round.workflow.ts
  • scripts/clippy-loop/fix-round.workflow.ts
  • scripts/clippy-loop/group-by-file.ts
  • scripts/clippy-loop/harvest.ts
  • scripts/clippy-loop/review-round.workflow.ts
  • scripts/clippy-loop/shard.ts
  • scripts/clippy-loop/split-diags.ts
  • src/base64/neonbase64
  • src/bun_core/lib.rs
  • src/collections/lib.rs
  • src/crash_handler/handle_oom.rs
  • src/crash_handler/lib.rs
  • src/js/bun/sql.ts
  • src/jsc/bindings/JSDOMWrapper.h
  • src/jsc/bindings/dh-primes.h
  • src/jsc/bindings/napi.h
  • src/jsc/bindings/node/crypto/KeyObject.h
  • src/jsc/bindings/webcore/DOMConstructors.h
  • src/jsc/bindings/webcore/JSPerformance.h
  • src/jsc/bindings/webcore/SerializedScriptValue.h
  • src/runtime/api/crash_handler_jsc.rs
  • src/runtime/cli/Arguments.rs
  • src/runtime/cli/mod.rs
  • src/uws_sys/Loop.rs
  • src/uws_sys/Response.rs
  • src/uws_sys/WebSocket.rs
  • src/uws_sys/_libusockets.h
  • src/uws_sys/h3.rs
  • src/uws_sys/lib.rs
  • src/uws_sys/libuwsockets.cpp
  • src/uws_sys/libuwsockets_h3.cpp
  • src/uws_sys/socket.rs
  • test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts
💤 Files with no reviewable changes (30)
  • src/jsc/bindings/node/crypto/KeyObject.h
  • src/jsc/bindings/dh-primes.h
  • scripts/clippy-loop/collect-pr-comments.sh
  • scripts/clippy-loop/de-unsafe.workflow.ts
  • scripts/clippy-loop/split-diags.ts
  • src/uws_sys/_libusockets.h
  • scripts/clippy-loop/review-round.workflow.ts
  • scripts/clippy-loop/edit-round.workflow.ts
  • src/jsc/bindings/webcore/JSPerformance.h
  • scripts/clippy-loop/apply-patches.ts
  • src/jsc/bindings/JSDOMWrapper.h
  • scripts/clippy-loop/shard.ts
  • scripts/clippy-loop/group-by-file.ts
  • src/uws_sys/h3.rs
  • scripts/clippy-loop/harvest.ts
  • src/jsc/bindings/napi.h
  • scripts/clippy-loop/collect-all-targets.sh
  • scripts/clippy-loop/fix-round.workflow.ts
  • src/js/bun/sql.ts
  • src/runtime/cli/Arguments.rs
  • scripts/clippy-loop/collect.sh
  • src/uws_sys/lib.rs
  • src/uws_sys/Response.rs
  • src/collections/lib.rs
  • src/uws_sys/Loop.rs
  • src/jsc/bindings/webcore/SerializedScriptValue.h
  • src/uws_sys/WebSocket.rs
  • src/uws_sys/socket.rs
  • src/uws_sys/libuwsockets_h3.cpp
  • src/uws_sys/libuwsockets.cpp

Comment thread src/jsc/bindings/webcore/DOMConstructors.h
Comment thread src/jsc/bindings/webcore/DOMConstructors.h Outdated
…'s file check

numberOfDOMConstructors now derives from DOMConstructorID::Count so a new
enum entry cannot silently index past ConstructorArray. existsInHead uses
git ls-tree and throws on git failure instead of reading any nonzero exit
as a deleted file.
Comment thread src/uws_sys/Loop.rs Outdated

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

Actionable comments posted: 1

🤖 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-uws-webcore-crash-scripts.test.ts`:
- Around line 49-50: Update the error constructed in the git ls-tree failure
branch to include repoRoot, r.exitCode, and a non-empty fallback when r.stderr
is empty, while preserving the existing stderr details when available. Keep the
failure associated with the path p and provide a clear remediation-oriented
diagnostic.
🪄 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: 7b26d373-ca1c-4d59-ba3b-438bdd27a3dc

📥 Commits

Reviewing files that changed from the base of the PR and between 716209c and 2a3cb93.

📒 Files selected for processing (2)
  • src/jsc/bindings/webcore/DOMConstructors.h
  • test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts

Comment thread src/jsc/bindings/dh-primes.h Outdated
Same class as the OPENSSL_ARRAY_SIZE removal: both macros supported
prime tables that no longer exist in this header, and the sole
includer (ncrypto.cpp) references neither.

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

Actionable comments posted: 1

🤖 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-uws-webcore-crash-scripts.test.ts`:
- Line 124: Update the regex in the dead-symbol test entry for
“src/jsc/bindings/dh-primes.h” to apply word boundaries to both deleted symbols,
using a grouped alternation for OPENSSL_ARRAY_SIZE and TOBN so longer
identifiers such as OPENSSL_ARRAY_SIZE_OLD do not match.
🪄 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: aa5d7fa8-47e7-44d3-9ab4-5cec83cdf8b2

📥 Commits

Reviewing files that changed from the base of the PR and between 2a3cb93 and 96ebb4a.

📒 Files selected for processing (2)
  • src/jsc/bindings/dh-primes.h
  • test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts
💤 Files with no reviewable changes (1)
  • src/jsc/bindings/dh-primes.h

Comment thread test/internal/source-lints/dead-symbols-uws-webcore-crash-scripts.test.ts Outdated

@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 large sweep (−2.4k lines across 37 files) that touches the per-GlobalObject DOM constructor array sizing, the uws HTTP/WebSocket C-ABI surface, and the top-level handle_root_error control flow, a human look would still be worthwhile.

What was reviewed:

  • DOMConstructors.h trim: retained IDs cover every DOMConstructorID:: reference; Count sentinel now sizes the array.
  • handle_root_error collapse: the InvalidArgument|Invalid Bunfig|InstallFailed arm still reaches Global::exit(1) on both SHOW_CRASH_TRACE settings with no new output.
  • uws wrapper deletions: each removed uws_* symbol has no remaining Rust extern or in-tree caller; *_with_options live paths kept.
  • HandleOom trait → plain fn: no remaining Result<T, crate::Error> / bare-Error callers; rust:check-all reportedly green.
Extended reasoning...

Overview

Dead-code sweep removing ~2,400 lines across four subsystems: 24 unused uws_* C-ABI wrappers plus their Rust extern declarations and safe-fn wrappers (Loop/Response/WebSocket/h3/socket); the DOMConstructorID enum trimmed from 849 to 51 entries with the WriteBarrier array now sized by a Count sentinel; the crash-handler error-return-trace apparatus (const-false-gated in Rust) including the --verbose-error-trace debug flag, the show_trace local, the StackLine Display impl, and the HandleOom trait collapsed to a plain fn handle_oom(Result<T, AllocError>); assorted C++ header cruft (NAPI_PERISH, TOBN, OPENSSL_ARRAY_SIZE, hasCustomPtrTraits, dead forward decls); the retired scripts/clippy-loop/ tooling; the orphan src/base64/neonbase64 bitcode blob; commented-out $create*Error helpers in bun/sql.ts; and a new source-lint test pinning the removed symbols.

Security risks

None identified. Pure deletions of unreferenced code plus doc/comment trims. No auth, crypto, permission, or input-validation logic is weakened; the only crypto-adjacent edit (dh-primes.h) removes unused macros. The handle_root_error change preserves exit codes and message output on every arm.

Level of scrutiny

High. Despite being deletions, the change reshapes a per-GlobalObject GC-visited array (DOMConstructors), removes 38 C-ABI symbols from the HTTP/WebSocket server FFI surface, changes a public crash-handler signature, and drops a debug-build CLI flag. Each of these is production-critical native code where a missed reference (especially from regenerated codegen or vendor/bun-uws internals) would be a compile break at best and an OOB array read at worst. The PR description's verification (grep across src/vendor/test/codegen, rust:check-all on 10 triples, full bun bd, targeted smoke tests) is thorough, but the scope is well past what should merge on automated review alone.

Other factors

All earlier review threads (mine and CodeRabbit's) are resolved by follow-up commits: the add_post_handler chain, show_trace remnant, DOMConstructors sentinel, TOBN macro, existsInHead git-failure handling, and rustfmt whitespace were all fixed. The bug-hunting system found nothing new this run. The added source-lint test follows the existing test/internal/source-lints/ pattern and reads HEAD to sidestep the git-stash stray-file issue. Given the breadth and the number of follow-up fixes already applied during review, a maintainer sign-off on the final state is appropriate.

@robobun

robobun commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

The single red in build 90524 is test/bake/deinitialization.test.ts on Windows 2019 x64 (the fixture dev server crashes with exit code 3 during teardown). Reproduced it on a Windows machine at about a 20 percent rate on this branch (3/15) and at the same rate on main f972c28 (5/25) with the identical crash, so it is a pre-existing teardown race unrelated to this diff; it has been reported separately. Everything else in the build passed or was retry-flake.

@robobun
robobun force-pushed the claude/farm/024726b1/dead-code-uws-webcore-semver-scripts branch from 88523d0 to b9d7aa9 Compare August 8, 2026 05:49
Comment thread src/crash_handler/lib.rs
Same class as the handle_root_error parameter this branch already
removed: both callers pass None, so the TraceSeed::ErrorReturn variant
and its match arms were unreachable. The enum loses its now-unused
lifetime parameter.
Comment thread src/crash_handler/lib.rs Outdated
The label existed for the removed TraceSeed::ErrorReturn early exit; the
block now ends in its tail expression.

@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 found no bugs; all earlier inline findings have been addressed. Given the breadth (net -2.4k lines across uws_sys FFI, the crash handler, and the DOMConstructors array sizing), a human sign-off is still worthwhile.

What was reviewed:

  • DOMConstructors.h trim: the 51 surviving DOMConstructorID entries match every getDOMConstructor<…> site in src/jsc/; the array is now sized from the Count sentinel and nothing casts the enum numerically.
  • handle_root_error control-flow: the removed show_trace branches and handle_error_return_trace_extra call sat behind HAVE_ERROR_RETURN_TRACING = false, so the early Global::exit(1) for InvalidArgument/Bunfig/InstallFailed collapsing to the tail exit is behavior-preserving.
  • bun_crash_handler::handle_oom trait → plain fn: only importer is js_parser/scan/scan_imports.rs with Result<T, AllocError>; the removed Error/bare-AllocError impls had no instantiations (cargo check on all 10 triples arbitrates).
  • uws_sys: spot-checked that the deleted Handler struct / add_*_handler / from_named_pipe / C wrappers have no remaining references, and the _with_options live paths stay intact.
Extended reasoning...

Overview

Dead-code sweep removing ~2,380 lines across 38 files: 24 unused C wrappers in libuwsockets.cpp and 14 in libuwsockets_h3.cpp plus their orphaned Rust extern declarations and safe wrappers (override_write_offset, add_pre/post_handler, Handler struct, from_named_pipe, us_fault_clear, LIBUS_LISTEN_DISALLOW_REUSE_PORT_FAILURE); the DOMConstructorID enum trimmed from 849 WebKit-inherited entries to the 51 bun references (also shrinking the per-GlobalObject WriteBarrier array); assorted dead C++ macros/forward decls (NAPI_PERISH, TOBN, OPENSSL_ARRAY_SIZE, hasCustomPtrTraits, MemoryHandle/FragmentedSharedBuffer); the crash handler's error-return-trace apparatus (const-false-gated in Rust) plus the always-None error_return_trace params on handle_root_error/panic_impl and the TraceSeed::ErrorReturn variant; the HandleOom trait collapsed to a plain Result<T, AllocError> fn; PriorityQueue::Default; the --verbose-error-trace debug flag; the scripts/clippy-loop/ one-shot tooling; the orphan neonbase64 bitcode blob; commented-out $create*Error helpers in sql.ts. A new source-lint test pins each removed symbol against reintroduction.

Security risks

None identified. No auth/crypto/permission logic changes — the touched crypto files (dh-primes.h, KeyObject.h) only lose unused macro scaffolding and a commented-out declaration. No input-handling paths are relaxed.

Level of scrutiny

High. This is not a mechanical config tweak: it rewrites handle_root_error control flow, changes a public fn signature (panic_impl, handle_root_error), drops a CLI flag, shrinks a per-GlobalObject GC-visited array's static size, and deletes ~300 lines of C++ FFI glue that backs Bun.serve's HTTP/WS paths. Each removal is individually verifiable as dead, and the Rust side is arbitrated by cargo check on all 10 triples plus a full debug build — but the aggregate surface across production-critical subsystems (HTTP server FFI, crash reporting, JSC DOM constructor caching) is large enough that a maintainer should confirm no removed symbol is load-bearing via a path grep can't see (e.g., in-flight branches, external tooling that parses --verbose-error-trace).

Other factors

The PR has been through four review iterations; every prior inline finding (mine and CodeRabbit's) is resolved, including the accidental restore commit (88523d0) that was force-dropped, the same-class siblings TOBN/add_post_handler/panic_impl's param, and the vestigial 'blk label. CI build 90524 was green except for a Windows bake/deinitialization.test.ts teardown flake reproduced at the same rate on main. The handle_root_error behavioral equivalence and DOMConstructors coverage were spot-checked directly against the tree in this review pass. Deferring for a human sign-off on scope, not on any identified defect.

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