Skip to content

Remove two commented-out blocks from CommonJS.ts and child_process.ts - #39926

Closed
robobun wants to merge 1 commit into
mainfrom
farm/039b59c5/remove-dead-commented-builtins
Closed

robobun wants to merge 1 commit into
mainfrom
farm/039b59c5/remove-dead-commented-builtins

Conversation

@robobun

@robobun robobun commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Adopts #39916 by @dylan-conway. The commit is his, rebased onto current main.

Problem

  • src/js/builtins/CommonJS.ts:184 holds a 130 line block comment with the old loadEsmIntoCjs implementation. It used Loader.registry, $setStateToMax and loader.parseModule. None of these exist since the module loader moved to C++. The live loadEsmIntoCjs above it is one call to $esmLoadSync.
  • src/js/node/child_process.ts:1955 holds a 130 line run of // comments. It is a copy of the E() and makeNodeErrorWithCode() helpers from Node's internal/errors. The file uses the native $ERR_INVALID_ARG_TYPE instead.

Fix

  • Delete both blocks. The diff removes 263 lines and adds none.
  • Every removed line is a comment or blank. In child_process.ts each removed line starts with // or is blank. In CommonJS.ts the removed lines are one /* ... */ block and the blank line after it.
  • The built output does not change. I ran src/codegen/bundle-modules.ts on main and on this branch, with --debug=OFF and with --debug=ON, into a directory with the same name. diff -r of the codegen/ and js/ output trees is empty in both modes. This covers WebCoreJSBuiltins.{h,cpp} and InternalModuleRegistryConstants.bin.
  • No test is added. A comment deletion has no behavior to test.

Background

  • src/js/builtins/*.ts are JSC builtin functions. src/codegen/bundle-functions.ts turns each exported function into a string table entry in WebCoreJSBuiltins.h.
  • src/js/node/*.ts are the node:* modules. src/codegen/bundle-modules.ts bundles them into InternalModuleRegistryConstants.bin. The bundler drops comments, so a comment only change cannot reach the binary.
  • Remove dead code from the JSC FFI glue, WebCore bindings, usockets, built-in JS, and orphaned scripts #39618 is a larger dead code PR. It contains these same two hunks among about 100 files. This PR lands the two hunks on their own.

@robobun

robobun commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: adopts #39916 at the request of @dylan-conway. The diff is the same commit (author unchanged), based on main at 4448a2e. Verified by a byte for byte compare of the bundle-modules.ts output on main and on this branch, in both codegen modes. No review threads are open.

CI: build 102542 passed 180 of 181 jobs. The one red test, test/js/workerd/html-rewriter-leak.test.ts on x64-asan (a UBSan null JSCell member call inside HTMLRewriter), is not reachable from a comment deletion that leaves the generated output identical. It is reported for main triage separately. The head commit was re-pushed once with an identical tree (59a90bc) to run CI again.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: af838833-9f8e-43a9-8fe3-c6b96bcb05e1

📥 Commits

Reviewing files that changed from the base of the PR and between 4448a2e and d785447.

📒 Files selected for processing (2)
  • src/js/builtins/CommonJS.ts
  • src/js/node/child_process.ts
💤 Files with no reviewable changes (2)
  • src/js/node/child_process.ts
  • src/js/builtins/CommonJS.ts

Included review availability: Your plan provides up to 5 included reviews per hour; 0 remain after this review.


Walkthrough

Changes

The PR removes obsolete commented-out implementations and scaffolding. Active runtime behavior and exported APIs remain unchanged.

Obsolete code removal

Layer / File(s) Summary
Remove legacy CommonJS loader
src/js/builtins/CommonJS.ts
The commented loadEsmIntoCjs__dead implementation and its manual module-loading logic were removed. The active $esmLoadSync implementation remains.

Merge Risk: ⚪ Minimal · up to d7854

This change only removes obsolete comments and does not alter generated output or runtime behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the change and verification steps, although it does not use the template headings exactly.
Title check ✅ Passed The title clearly and concisely identifies the removal of the two commented-out blocks.
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.

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

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

LGTM — pure comment/blank-line deletion with no behavioral change.

What was reviewed:

  • Confirmed every removed line is inside a /* ... */ block (CommonJS.ts) or a // line/blank (child_process.ts); zero lines added.
  • The live loadEsmIntoCjs and $ERR_INVALID_ARG_TYPE paths that supersede the commented code remain intact in the post-change files.
  • Codegen strips comments before emitting WebCoreJSBuiltins.* / InternalModuleRegistryConstants.bin, so the built binary is unchanged (author verified with diff -r on both debug modes).
Extended reasoning...

Overview

This PR deletes two large commented-out code blocks: a ~130-line /* ... */ block in src/js/builtins/CommonJS.ts containing the legacy loadEsmIntoCjs implementation (dead since the module loader moved to C++), and a ~130-line run of // comments in src/js/node/child_process.ts containing a never-used copy of Node's E()/makeNodeErrorWithCode() helpers. The diff is -263/+0. Every removed line is a comment or blank; no executable code, exports, or declarations are touched.

Security risks

None. Comments are stripped by bundle-functions.ts and bundle-modules.ts before reaching the compiled binary, so this change cannot alter runtime behavior in any way. No auth, crypto, permissions, or user-input handling is involved.

Level of scrutiny

Minimal. This is the canonical low-risk change: mechanical dead-comment removal with a verifiable claim that the generated artifacts are byte-identical. The author ran the codegen on both branches with --debug=ON and --debug=OFF and confirmed diff -r is empty. Per the repo's own review guidance ("Delete dead code in the same PR that makes it dead"), this is exactly the kind of cleanup that should land without friction.

Other factors

No prior reviews or outstanding comments on the PR. No test is added, which is correct — a comment-only deletion has no behavior to test, and the repo guidance's "every behavioral change ships a test" rule does not apply to non-behavioral changes. The bug hunting system found no issues. The two hunks are extracted from a larger dead-code PR (#39618) to land independently, which reduces review surface.

@robobun

robobun commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 3:22 AM PT - Aug 21st, 2026

✅ @dylan-conway, your commit 59a90bce5a9e2ff66f10d7e37404cbe7d1f1a537 passed in Build #102551! 🎉


🧪   To try this PR locally:

bunx bun-pr 39926

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

bun-39926 --bun

…ess.ts

Both were dead: a ~130-line legacy loadEsmIntoCjs implementation kept inside a
block comment after the module-loader rewrite, and a ~130-line commented-out
copy of Node's internal/errors registration helpers in child_process.ts. They
are stripped by the builtin bundler anyway; this just removes them from the
source.

No-Verification-Needed: comment-only deletion
(cherry picked from commit 68069bf)
@robobun
robobun force-pushed the farm/039b59c5/remove-dead-commented-builtins branch from d785447 to 59a90bc Compare August 21, 2026 10:03

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

LGTM — pure comment deletion, no code changed.

What was reviewed:

  • Confirmed every removed line in both hunks is inside a /* */ block comment, a // line comment, or blank; zero lines added.
  • The live loadEsmIntoCjs ($esmLoadSync) and ERR_UNKNOWN_SIGNAL that follow the deleted blocks are intact in the post-diff files.
  • Checked that no identifier inside the deleted comments (e.g. loadEsmIntoCjs__dead, makeNodeErrorWithCode) is referenced elsewhere — it was all inert.
Extended reasoning...

Overview

This PR deletes two large commented-out code blocks: a ~130-line /* ... */ block in src/js/builtins/CommonJS.ts containing the obsolete loadEsmIntoCjs__dead implementation (which relied on the removed JS-side Loader.registry/$setStateToMax/parseModule machinery), and a ~130-line run of // comments in src/js/node/child_process.ts containing a dead copy of Node's E()/makeNodeErrorWithCode() error-registration scaffolding. The diff is -263/+0; no executable line is touched.

Security risks

None. Comments are stripped by bundle-functions.ts and bundle-modules.ts before reaching the generated WebCoreJSBuiltins.h / InternalModuleRegistryConstants.bin, so the shipped binary is byte-identical (the PR description confirms this via diff -r on codegen output in both debug modes). There is no attack surface change.

Level of scrutiny

Minimal. This is the canonical "delete dead code" case the repo's review guidelines explicitly require (dead comments narrating superseded implementations). Every removed line was verified to be a comment or blank — there is no possibility of behavioral change, and no test is expected for a comment-only deletion.

Other factors

The commit is authored by a maintainer (dylan-conway) and adopted from #39916. CI build 102542 passed 180/181 jobs; the single failure (html-rewriter-leak.test.ts UBSan on x64-asan) is in unrelated native HTMLRewriter code and cannot be reached by a change that leaves generated output identical. No prior review threads are open and I have not reviewed this PR before.

@robobun

robobun commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

Closing. The same commit landed on main directly through #39916 (218ef44). The patch in this PR is identical to that commit, and a cherry-pick of it onto current main produces no change. This adoption PR has nothing left to add.

@robobun robobun closed this Aug 22, 2026
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