Move TestController to Rust and deliver test() through the entrypoint crate #8736
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 273 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.336
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8736"
general
weight: 0.35
bartlomieju
The test event is the first event whose handler call runs in Rust, not
just its delivery.
TestController, the first argument of atest()handler, becomes a Rust
#[jsg_resource]in the newtest-apicrate,and
WorkerEntrypoint::test()hands the event to theentrypointcrate, which reports it to the tracer, delivers it, calls
test()in awaitUntil task and finishes the request with
finishScheduled(). Thereis no autogate: only test runners deliver the test event, so no
production request reaches this path. The first commit adds what the
event needs from
io_context,incoming_request_run_in_wait_until(),which is
context.addWaitUntil(context.run(...)). It runs a C++prelude, which finds the handler and its
test(), before Rust holds thelock, so no C++ JSG runs under a Rust-held lock and a throwing class
constructor fails the run as in C++. A JavaScript error from the Rust
function is logged as uncaught, a KJ exception reaches
run()unchangedunless a JavaScript exception is pending, which then wins, and the
crate's shims use no C++ JSG.
The event behaves as it did in C++, and production Workers see no
change.
ExportedHandlerkeeps itstestmember, read when the exportis loaded, but untyped, since a
jsg::Functionsignature can't name theRust
TestController. The oldServiceWorkerGlobalScope::test()becomes
getTestHandler(), which makes the same twoJSG_REQUIRE_NONNULLchecks, so Service Workers syntax and an exportwithout
test()fail with the exceptions C++ threw. The one differenceis that, for a test whose promise rejects, the
--verboselog linescome from
io-context/ffi.c++andrust/jsg/lib.rsrather thanworker.c++andvalue.h, since Rust handles the rejection. ThePerfetto spans keep their names and extents:
WorkerEntrypoint::test()covers the whole wait, as in C++, on a track of itswaitForFinished()
own.
io-context-testcovers the run's prelude, failures and panics,test-api's unit tests cover the controller, andtest-controller-test,server-testandserver/tests/test-eventcover how
test()is called and how failures are reported. Those threealso pass against the C++ path on main.