Skip to content
Commit Detail

Commit 901a13d

Author
James M Snell <jsnell@cloudflare.com> 2025-08-28 14:22:24 -0700
Parents
f772a92
Tree
7716f19
Cleanup ownership module for new module registry

Make the new module registry an AtomicRefcounted.

While in workerd every new module registry instance will
be owned by exactly one Worker, in production many replicas
of a worker will share the same module registry instance,
with each kj::Arc instance being held by a different
Worker::Script instance.

Move ownership of the registry instance from Api to Script.

Following the lessons learned when doing the enablement
for the virtual file system, the module registry instance
needs to be owned by the Worker::Script instance, not the
Worker::Api instance. This is largely because of preview
sessions but also just because it makes more sense on
the script.

While we're at it, clean up some parts of the API that
are relevant to this ownership changes, specifically
the AtomicRefcounted change (e.g. marking things const
where appropriate).

Files changed