Remove dead code and deduplicate helpers across src/ - #31912
Closed
alii wants to merge 18 commits into
Closed
Conversation
Collaborator
Contributor
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
… fix windows-only unused import
alii
force-pushed
the
claude/simplify-dead-code-pass
branch
from
June 6, 2026 03:42
590c8d0 to
3cd193f
Compare
…tatus, and remaining helper consolidations
alii
force-pushed
the
claude/simplify-dead-code-pass
branch
from
June 6, 2026 18:48
1157bd2 to
46ad414
Compare
…lenient notice decode
…SON5/YAML space handling, and per-driver sql failure timing
This was referenced Jun 8, 2026
This was referenced Jun 9, 2026
alii
added a commit
that referenced
this pull request
Aug 11, 2026
## What this does Dedupes webcore lifecycle boilerplate with zero intended behavior change: - `impl_file_closer!` (Blob.rs): shared `FileCloser` impl for blob `ReadFile`/`WriteFile`. The two hand-written impls were functionally identical; `ReadFile` gains `bun_io::intrusive_io_request!` so both recover the parent through `IntrusiveIoRequest` instead of an open-coded `from_field_ptr!`. `ReadFileUV` keeps its own impl (different shape). - `impl_js_sink_forwarders!` (Sink.rs, next to `impl_js_sink_abi!`): the eight 1:1 `JsSinkType` forwarders shared by `ArrayBufferSink`, `FileSink`, `FetchRequestBodySink`, `HTTPServerWritable`, and `NetworkSink`. Per-sink items (`finalize`, `construct`, `end_from_js`, `source`, `done`, `HAS_*`) stay hand-written. - `CopyFile::fallback_read_write`: the `read_write_fallback` call plus error recording appeared three times in `do_copy_file_range`. - `Blob::set_content_type_from_js` and `S3File::finish_s3_blob`: the write-path `options.type` override (in `do_write` and `get_writer`) and the S3 constructor epilogue (in both `construct_s3_file_with_s3_credentials*` fns) were each duplicated verbatim. - `S3File::parse_s3_path_or_blob`/`resolve_s3_blob` and `S3Client::construct_blob`/`blob_and_options`: shared argument parsing for the S3 static and instance methods. `MissingPathError` preserves the per-method split between `MISSING_ARGS` and invalid-argument errors (`unlink` always reports `MISSING_ARGS`; the others only when no argument was passed). - The explicit 14-arm typed-array `JSType` lists in Blob construction use the existing `JSType::is_array_buffer_like()` (same 14-type set). Net -401 lines of src. ## History Originally the top of the foundations/install-cli/jsc-runtime stack split from #31912. Main moved far enough that every file conflicted, so this was re-derived against current main and retargeted at `main`; it has no code dependency on the other PRs in that stack. ## Tests The consolidated paths had no coverage of their error contracts, so this adds characterization tests pinning them: - `test/js/bun/s3/s3-argument-validation.test.ts`: per-method static rejection messages (including `stat` reusing the "get size" wording), the instance-method `ERR_MISSING_ARGS` vs `ERR_INVALID_ARG_TYPE` split, `unlink` always reporting `MISSING_ARGS`, and the S3 `writer()` non-string `type` rejection - `test/js/web/fetch/blob-write.test.ts`: `Bun.file().write()` `options.type` contract (non-string throws, valid types lowercased, known types resolved through the mime table, invalid types ignored) - `test/js/web/fetch/blob.test.ts`: Blob construction from all 14 ArrayBuffer-like types, as a direct body value and as an array part Because this is a behavior-preserving refactor, these tests pass identically with and without the src changes by design; that is the equivalence check, not a gap. ## Verification - Line-by-line audit against main for each consolidation: error messages, argument-eating order, drop order, and the unsafe parent-pointer recovery in `schedule_close`/`on_close_io_request` are unchanged (the macro's two trampolines are `WriteFile`'s current impl statement for statement, differing only in fully-qualified paths; `ReadFile` moves from its older `&mut *from_field_ptr!` form onto that same already-landed shape) - `bun run rust:check-all`: all 10 CI target triples pass - Debug (ASAN) build: the three test files above (102 pass), sink suites plus request-body and server-response stream suites (9161 pass), `Bun.write` including both `copyFileRange`-unavailable fallback tests, local S3 suites (38 pass), blob/FormData suites (165 pass). The large-file fallback test needs more than the 5s default on this ASAN box with or without the change. <!-- robobun:evidence:begin --> --- **no test proof** · iteration 17 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/js/web/fetch/blob.test.ts <!-- robobun:evidence:end --> --------- Co-authored-by: robobun <117481402+robobun@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A repo-wide cleanup pass over
src/: deleting dead code and consolidating duplicated logic into shared helpers. Net −17,825 lines (206 files, +11,497 / −29,322 vs the base commit).What changed
Dead code removed:
host_fns.rs+ draft types inffi/mod.rs, ~620 lines) — only reference was an unused re-export#[cfg(any())]-parked 1,188-variant MS-ERREF error table insrc/sys/windows/mod.rs(~2,800 lines)WinsockErrortable + caller-less converter (−219)bun_resolver::cache::Fs(every live caller already used the resolver's)Duplication consolidated (monomorphization-preserving — macros/const generics, no vtables added):
OutputTaskVTableimpls → one macro#[inline]generic insrc/parsers/number_scan.rs(diffed against both reference implementations)src/js/internal/sql/shared.ts,src/sql/shared/init_transpilertwins, link/unlink and outdated/update-interactive CLI helper blocks, bundler parse-task dispatch tail, cron/node_fs/CryptoHasher/hosted_git_info helper dedupsVerification
cargo checkwas additionally run forx86_64-pc-windows-msvcandx86_64-unknown-linux-gnu— both pass, all 10 workspace cross-targets greenReviewer notes
src/css/compat.rswas converted from a generatedmatchto a data table (equal-or-faster, verified) — but it's no longer regenerable bybuild-prefixes.jsas-is. If we'd rather keep it generator-owned, I can revert that one commit's hunk or update the generator to emit the table form.bun add/update, postgres NoticeResponse short-length tolerance, macro-map parsing, JSON5/YAML space handling, SQL driver failure timing, pool slot guards — has been reverted to match main exactly. Where a dedup could not preserve behavior, the dedup itself was reverted.#[allow(dead_code)]insrc/router/lib.rs; resolved by deleting the orphaned cfg(test) fixture scaffolding (266 lines, plus its now-unused dev-dependency), not by updating the inventory.bunx.test.ts"requires node 24" failure is pre-existing on main; the darwinAsyncLocalStorage-trackingfs-watch exit segfault is the known FSEventsLoop shutdown race (fs.watch(macOS): make FSEventsLoop Sync and retain the CFRunLoop across shutdown #30758 — identical stack, fault address 0xC, filed before this branch existed; every file in that crash path is byte-identical to main here).