Load the Pyodide bundle in Rust #8202
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 433 lines diff across 5 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.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8202"
general
weight: 0.35
ryanking13
The workerd server now fetches, caches and verifies the Pyodide bundle
a Python worker needs in Rust (
server/server/pyodide.rs) instead ofin C++ (
server/pyodide.c++).preloadPython()in the worker factory returns early if the bundleis already loaded. Otherwise it awaits the server's
pyodide_bundle_fetch()for the verified bytes and passes them toPyodideBundleManager::setPyodideBundleData(), unless anotherworker loaded the same bundle meanwhile. The Rust side makes no
calls back into C++.
pyodide_bundle_fetch()returns an emptyVecwhen there is nobundle (an uncached "dev"), since the cxx fork's
KjMaybecannothold a
Vecyet; a TODO marks the switch toKjMaybe<Vec<u8>>. Anempty bundle file is an error rather than no bundle.
The bundle is read from
pyodide_<version>.capnp.binin--pyodide-bundle-disk-cache-dir, or else downloaded from the sameURL as before. The download is one HTTP/1.1 GET over hyper on the
loop's tokio runtime. The result is written to the cache through a
temporary file that is synced to disk and renamed. The cache is
read and written on tokio's blocking pool, as a bundle is tens of
MB.
Unchanged: "dev" is never downloaded, a status other than 200
fails, the cache is written only after a download that passed the
integrity check, and the integrity rules (SHA-256 subresource
integrity, required for every bundle but "dev") are the same. The
cache directory is still resolved against the working directory at
startup, as kj resolved it.
The C++ fetcher,
computePyodideBundleIntegrity(),verifyPyodideBundleIntegrity()andPythonConfig::pyodideDiskCacheRootare removed. Their C++ testsare now Rust unit tests in
server/server/pyodide-test.rs, whichalso cover the cache and the download against a local hyper server,
over plain HTTP and over TLS with a test CA (SNI,
Hostand anuntrusted certificate included).
Nothing in the workerd binary depends on kj-tls any more. The
second commit drops it from
workerd-api, along with a staleinclude.
Behaviour that changes:
The trust store. kj's
useSystemTrustStoreloaded BoringSSL'sdefault paths (
SSL_CERT_FILE, else/etc/ssl/cert.pem, andSSL_CERT_DIR, else/etc/ssl/certs), plus the system store onWindows. The download now uses kj-hyper's rustls with
rustls-platform-verifier 0.7: Security.framework (the Keychain) on
macOS, the Windows certificate store on Windows, and
rustls-native-certs on Linux, which still honors
SSL_CERT_FILEand
SSL_CERT_DIRand otherwise probes the usual bundle locations.On macOS, roots added to the Keychain now count, and
SSL_CERT_FILE/SSL_CERT_DIRno longer do; on Windows the twovariables no longer count either.
Two Python workers (dynamic workers, say) that both download the
same version at once no longer fail on a duplicate insert into the
bundle manager; the second one finds the bundle loaded and drops
its copy.
Whether the cache directory exists is checked on each load, not
once at startup.
Network errors, resolving and connecting included, name the
Pyodide bundle URL and keep the underlying exception type.
--pyodide-bundle-disk-cache-dirthat resolves to a path that isnot UTF-8 (a relative path under such a working directory) fails at
startup, as the server takes the directory as a string.
This adds no new JS-visible API and no compatibility flag.