Skip to content

Deduplicate webcore blob, sink, and S3 helpers#32024

Open
alii wants to merge 6 commits into
claude/split/jsc-runtimefrom
claude/split/webcore
Open

Deduplicate webcore blob, sink, and S3 helpers#32024
alii wants to merge 6 commits into
claude/split/jsc-runtimefrom
claude/split/webcore

Conversation

@alii

@alii alii commented Jun 9, 2026

Copy link
Copy Markdown
Member

What this does

Dedupes webcore lifecycle boilerplate with zero intended behavior change:

  • impl_file_closer!: shared FileCloser impl for blob ReadFile/WriteFile (the two hand-written impls were functionally identical; ReadFile gains bun_io::intrusive_io_request! so both go through the IntrusiveIoRequest trait)
  • impl_js_sink_forwarders!: shared JsSinkType forwarder methods for ArrayBufferSink, FileSink, HTTPServerWritable, and NetworkSink
  • CopyFile::fallback_read_write: the read/write-loop fallback block appeared three times in do_copy_file_range
  • Blob::set_content_type_from_js and S3File::finish_s3_blob: the two write-path content-type override blocks and the two S3 constructor epilogues were byte-identical copies
  • S3File::parse_s3_path_or_blob/resolve_s3_blob and S3Client::blob_and_options: shared argument parsing for the S3 static and instance methods; the MissingPathError enum preserves the per-method split between MISSING_ARGS and invalid-arguments errors
  • Explicit typed-array JSType match lists in Blob construction replaced with the existing JSType::is_array_buffer_like() (same 14-type set)

Net -411 lines of src.

Top of the stack, merge order: foundations → install-cli → jsc-runtime → this. Split from #31912 (whole-repo simplification pass; closing that PR in favor of module-scoped splits).

Tests

The consolidated paths had no existing 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 split between ERR_MISSING_ARGS (no argument) and ERR_INVALID_ARG_TYPE (non-path argument), 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 silently 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 PR is a behavior-preserving refactor, there is deliberately no test that fails without the src change: the tests pass identically on the base tree and on this branch (verified by running both), which is the equivalence proof for the refactor rather than a gap in the tests.

Verification

  • Line-by-line diff audit against the base branch: error messages, argument-eating order, drop order, and ownership are all preserved
  • cargo check --workspace passes on all 10 CI target triples (bun run rust:check-all)
  • Debug-build test runs: sink suites (48 pass), blob suites (48 pass), FormData (129 pass), local S3 suites (31 pass), Bun.write (30 pass plus 5 slow-machine timeouts that reproduce identically on the base branch)

@robobun

robobun commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator
Updated 3:16 AM PT - Jun 10th, 2026

@robobun, your commit d473d99 has 1 failures in Build #61719 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 32024

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

bun-32024 --bun

@alii

alii commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@robobun adopt

@robobun robobun force-pushed the claude/split/webcore branch from d257e67 to 2552851 Compare June 9, 2026 20:48
@robobun

robobun commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Adopted and verified: full diff audit for behavioral equivalence, cargo check on all 10 CI targets, and the sink, blob, FormData, Bun.write, and S3 suites pass on a debug build. Characterization tests for the consolidated error contracts are included (details in the PR body).

Final CI state (build 61719): 281 jobs passed; the only test failure is a one-off segfault of @duckdb/node-api/duckdb.test.ts on one debian x64-baseline shard, in N-API code this webcore-only diff does not touch (passes under ASAN with this diff locally; same test has prior napi crash history, see #29324). 4 darwin jobs expired waiting for agents. Retrying the failed and expired jobs should green the build. Ready for review.

robobun and others added 5 commits June 9, 2026 21:04
Pin the error contracts and type dispatch the dedup consolidated:
S3 static and instance method argument validation (per-method
messages, MISSING_ARGS vs INVALID_ARG_TYPE split), the
Bun.file().write() and S3 writer() options.type override, and Blob
construction from every ArrayBuffer-like type as both a direct body
value and an array part.
s3-fd-validation.test.ts also contains a test that needs unproxied
localhost egress; the validation contract tests are all synchronous
rejections with no network dependency, so they get a self-contained
file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants