PR #10621 fixed class X extends AsyncResource for every syntax that reaches the value indirectly (local alias,
namespace member, CJS destructured require()) by generalizing bound_native_callable_module_and_method in
crates/perry-runtime/src/object/global_this/fetch_globals.rs to recognize ("async_hooks", "AsyncResource")
and route to js_async_resource_subclass_init.
AsyncLocalStorage has the same defect shape and was deliberately left unfixed, for a structural reason: its
init helper lives in perry-stdlib, and perry-runtime cannot depend on perry-stdlib. So the same one-line
recognition arm is not available without either moving the helper down into perry-runtime or introducing an
indirection (a registration hook the stdlib installs at startup, which is how other cross-crate surfaces are
wired).
Deciding which of those two shapes is right is the actual work here; the detection half is already solved and
can be copied from #10621's diff.
Note AsyncLocalStorage is not a stub — real tracking across await/microtasks/timers landed in #788 — so this
is about subclassing it, not about its behaviour.
PR #10621 fixed
class X extends AsyncResourcefor every syntax that reaches the value indirectly (local alias,namespace member, CJS destructured
require()) by generalizingbound_native_callable_module_and_methodincrates/perry-runtime/src/object/global_this/fetch_globals.rsto recognize("async_hooks", "AsyncResource")and route to
js_async_resource_subclass_init.AsyncLocalStoragehas the same defect shape and was deliberately left unfixed, for a structural reason: itsinit helper lives in
perry-stdlib, andperry-runtimecannot depend onperry-stdlib. So the same one-linerecognition arm is not available without either moving the helper down into
perry-runtimeor introducing anindirection (a registration hook the stdlib installs at startup, which is how other cross-crate surfaces are
wired).
Deciding which of those two shapes is right is the actual work here; the detection half is already solved and
can be copied from #10621's diff.
Note
AsyncLocalStorageis not a stub — real tracking acrossawait/microtasks/timers landed in #788 — so thisis about subclassing it, not about its behaviour.