← Back to Pull requests

Move TestController to Rust and deliver test() through the entrypoint crate #8736

Closed
unknown closed this pull request without merging on Nov 26, 2026 21:33 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 11:52 UTC
Author

The test event is the first event whose handler call runs in Rust, not
just its delivery. TestController, the first argument of a test()
handler, becomes a Rust #[jsg_resource] in the new test-api crate,
and WorkerEntrypoint::test() hands the event to the entrypoint
crate, which reports it to the tracer, delivers it, calls test() in a
waitUntil task and finishes the request with finishScheduled(). There
is 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 the
lock, 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() unchanged
unless 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. ExportedHandler keeps its test member, read when the export
is loaded, but untyped, since a jsg::Function signature can't name the
Rust TestController. The old ServiceWorkerGlobalScope::test()
becomes getTestHandler(), which makes the same two
JSG_REQUIRE_NONNULL checks, so Service Workers syntax and an export
without test() fail with the exceptions C++ threw. The one difference
is that, for a test whose promise rejects, the --verbose log lines
come from io-context/ffi.c++ and rust/jsg/lib.rs rather than
worker.c++ and value.h, since Rust handles the rejection. The
Perfetto spans keep their names and extents: WorkerEntrypoint::test()
waitForFinished()
covers the whole wait, as in C++, on a track of its
own. io-context-test covers the run's prelude, failures and panics,
test-api's unit tests cover the controller, and
test-controller-test, server-test and server/tests/test-event
cover how test() is called and how failures are reported. Those three
also pass against the C++ path on main.

Diff: 273 lines (+204 / -69) across 3 files Reviewer: bartlomieju Review duration: 9220m
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
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.5% (MEDIUM) · Higher = larger blast radius
39.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.6% · Safe to merge
15.6%