Skip to content

Throw a failing Rust builtin module's own error in the new module registry - #8581

Merged
littledivy merged 1 commit into
mainfrom
littledivy/2026-11-18-audit-rjsg-modules
Nov 19, 2026
Merged

littledivy merged 1 commit into
mainfrom
littledivy/2026-11-18-audit-rjsg-modules

Conversation

@littledivy

Copy link
Copy Markdown
Member

When a Rust builtin module's callback failed, RustBuiltinModuleAdapter threw jsg::JsExceptionThrown out of the synthetic module's evaluate callback. The new registry's evaluationSteps catches every C++ exception with KJ_CATCH, so the importer got Error: internal error instead of the module's own error, and the runtime logged "Uncaught JsExceptionThrown". The legacy registry already passes the error through.

In this patch the adapter returns false with the exception pending, as the text, data and JSON module handlers do, so V8 throws the module's own error. The legacy adapter still throws JsExceptionThrown, which its registry expects. io-context-test now imports a failing Rust module twice through each registry. The new-registry case fails without the fix.

…istry

When the callback of a Rust builtin module failed, RustBuiltinModuleAdapter threw jsg::JsExceptionThrown out of the synthetic module's evaluate callback. The new registry's evaluationSteps catches every C++ exception with KJ_CATCH, so the importer got "Error: internal error" instead of the module's error, and the runtime logged "Uncaught JsExceptionThrown". The legacy registry already passes the error through.

In this patch the adapter returns false with the exception pending, as the text, data and JSON module handlers do, so V8 throws the module's own error. The legacy adapter still throws JsExceptionThrown, which its registry expects. io-context-test now imports a failing Rust module twice through each registry. The new-registry case fails without the fix.
@littledivy
littledivy requested review from a team as code owners November 18, 2026 04:45

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — This is a small, correct fix that follows how the existing synthetic modules report errors, and it adds tests for both registries. I found no issues.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No issues found.


📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No issues found.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: a6884f1b

@guybedford guybedford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Verified locally that the new-registry test fails with Error: internal error without the adapter change and passes with it.

Comment thread src/rust/jsg/jsg.h Resolved
@littledivy
littledivy merged commit f302d51 into main Nov 19, 2026
23 of 24 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-18-audit-rjsg-modules branch November 19, 2026 07:28
littledivy added a commit that referenced this pull request Nov 20, 2026
#8581 and #8597 fixed how the new module registry reports a failing
Rust builtin module callback, and the commit messages cover a
termination as well as a thrown error. Only the thrown error was tested
for Rust modules.

In this patch a Rust test module's callback terminates execution, and a
test for each registry checks that resolving it throws with the
termination still in place. With both fixes reverted, the new
registry's test fails because an internal error replaces the
termination.
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