Skip to content

Remove the unused function-slot vector from JSCommonJSExtensions - #41405

Merged
dylan-conway merged 1 commit into
mainfrom
claude/remove-dead-cjs-extension-slots
Sep 4, 2026
Merged

dylan-conway merged 1 commit into
mainfrom
claude/remove-dead-cjs-extension-slots

Conversation

@dylan-conway

Copy link
Copy Markdown
Member

What does this PR do?

Deletes a leftover from the original require.extensions implementation. Since #19231, custom loader functions are kept alive by Strong handles on the Rust side (CustomLoader::Custom). The mechanism that change replaced — a WTF::Vector<WriteBarrier<Unknown>> member on the JSCommonJSExtensions cell, the JSCommonJSExtensions__appendFunction / __setFunction / __swapRemove externs that mutated it, and a visitChildren override that walked it — has had no callers since then; NodeModuleModule.rs only declared the externs. This removes the vector, the three externs, the visitChildren override, the declared-but-never-defined destructor, and the Rust extern block.

Worth removing rather than leaving: the vector was mutated and visited without cellLock(), unlike every other Vector<WriteBarrier> member in our cells, so reviving it as-is would have raced the concurrent marker.

No behaviour change: the vector was always empty, so the override only ever called Base::visitChildren.

How did you verify your code works?

  • grep across src/ for the three extern names and m_registeredFunctions: the only references were the definitions and the Rust declarations removed here.
  • Compiled JSCommonJSExtensions.cpp with the release flags (-fsyntax-only) after the change; clean. Relying on CI for the full build and the existing require.extensions tests (test/js/node/module).

require.extensions has kept custom loader functions alive through Strong
handles on the Rust side since #19231. The older mechanism it replaced -
a WTF::Vector<WriteBarrier<Unknown>> on the JSCommonJSExtensions cell,
the JSCommonJSExtensions__appendFunction / __setFunction / __swapRemove
externs that mutated it, and the visitChildren override that walked it -
has had no callers since then: the Rust module only declared the externs.
Delete the vector, the three externs, the visitChildren override, the
never-defined destructor declaration, and the Rust extern block.
@coderabbitai

coderabbitai Bot commented Sep 4, 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: Essentials

Run ID: a1f7cccb-5f94-43f0-8cca-844b01c60f17

📥 Commits

Reviewing files that changed from the base of the PR and between 86b2e06 and fd9e576.

📒 Files selected for processing (3)
  • src/jsc/NodeModuleModule.rs
  • src/jsc/bindings/JSCommonJSExtensions.cpp
  • src/jsc/bindings/JSCommonJSExtensions.h
💤 Files with no reviewable changes (3)
  • src/jsc/bindings/JSCommonJSExtensions.cpp
  • src/jsc/NodeModuleModule.rs
  • src/jsc/bindings/JSCommonJSExtensions.h

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


Walkthrough

The change removes registered-function storage and garbage-collection visitation from JSCommonJSExtensions. It also removes the corresponding exported C++ helpers and Rust FFI declarations.

Changes

Registered function cleanup

Layer / File(s) Summary
Remove registered-function storage and visitation
src/jsc/bindings/JSCommonJSExtensions.h, src/jsc/bindings/JSCommonJSExtensions.cpp
JSCommonJSExtensions no longer stores registered functions or registers a garbage-collection visitor for them.
Remove registered-function APIs
src/jsc/bindings/JSCommonJSExtensions.cpp, src/jsc/NodeModuleModule.rs
The appendFunction, setFunction, and swapRemove C ABI implementations and declarations are removed.

Merge Risk: ⚪ Minimal · up to fd9e5

The change removes unused extension-function registration plumbing without any identified remaining merge-readiness risk.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: removing the unused function-slot vector from JSCommonJSExtensions. It is concise and related to the broader cleanup.
Description check ✅ Passed The description includes both required sections. It explains the removed mechanism, why it is unused, expected behavior, concurrency concerns, and verification steps.
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 dead-code removal.

What was reviewed:

  • Grepped src/ for the three removed extern names and m_registeredFunctions — no remaining references anywhere.
  • Confirmed CustomLoader::Custom(Strong) in NodeModuleModule.rs is what roots user-supplied loader functions; on_require_extension_modify never called the removed externs, so the vector was always empty and visitChildrenImpl only ever forwarded to Base.
  • The removed ~JSCommonJSExtensions() had no definition and no destroy() override to reach it — it was already dead. No WriteBarrier members remain, so dropping DECLARE_VISIT_CHILDREN is safe.
Extended reasoning...

Overview

This PR deletes 70 lines across three files with zero additions. It removes WTF::Vector<WriteBarrier<Unknown>> m_registeredFunctions from JSCommonJSExtensions, the visitChildrenImpl/DEFINE_VISIT_CHILDREN that traced it, a declared-but-undefined destructor, three extern "C" mutators (__appendFunction/__setFunction/__swapRemove), and the matching Rust extern "C" block in NodeModuleModule.rs. The stated reason is that since an earlier PR, custom require.extensions loaders are kept alive by Rust-side Strong handles, making this C++-side rooting mechanism a vestigial leftover with no callers.

Security risks

None. This is deletion of unreferenced native code. No user-facing surface changes, no new parsing, no auth/crypto/permissions paths touched.

Level of scrutiny

Moderate — the REVIEW.md rule "don't silently delete existing [GC roots]" required verifying that the deleted WriteBarrier vector was genuinely redundant, not load-bearing. I confirmed this directly: CustomLoader::Custom(Strong) at src/jsc/NodeModuleModule.rs:116 holds the loader function via a Strong handle created in on_require_extension_modify (lines 148, 156, 158), and that function contains no calls to the removed externs. A repo-wide grep for all four removed identifiers returned zero hits. The vector had no writers, so it was always empty; the removed visitChildren therefore never appended anything beyond Base::visitChildren.

Other factors

The removed ~JSCommonJSExtensions() declaration had no definition anywhere (grep confirms), and the class defines no destroy() override — CREATE_METHOD_TABLE inherits JSDestructibleObject::destroy, which never reached the derived destructor anyway. So the declaration was already dead. The class still derives from JSDestructibleObject despite now having no C++ fields; switching to JSNonFinalObject would be a minor optimization but touches subspace/structure plumbing and is reasonably out of scope for a focused deletion PR. No behavior change, so no new test is expected per REVIEW.md; existing require.extensions coverage in test/js/node/module applies.

@robobun

robobun commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 4:16 PM PT - Sep 4th, 2026

❌ @dylan-conway, your commit fd9e576 has 2 failures in Build #110284 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 41405

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

bun-41405 --bun

@dylan-conway
dylan-conway merged commit 814fa03 into main Sep 4, 2026
10 of 12 checks passed
@dylan-conway
dylan-conway deleted the claude/remove-dead-cjs-extension-slots branch September 4, 2026 23:32
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