#47747·servo

Convert uses of Rc<Promise> to RootedPromise or TracedPromise

Author: jdmCreated Sep 2, 2026Updated Sep 17, 2026
LabelsA-content/domE-less-complexI-perf-bloat

As discovered in #45262, we leak memory due to how we store Rc<Promise> objects that cannot be GCed inside of our DOM objects that are traced by the GC. #47682 and #47735 give us the tools to fix this problem, and we're going to do it in bite-size pieces.

Common patterns:

  • TrustedPromise::new(rc_promise.clone()) -> TrustedPromise::from(rooted_promise)
  • some method that returns -> Rc<Promise> becomes -> RootedPromise, and any calls to Promise::new_in_realm/Promise::new_resolved/Promise::new_rejected get a _rooted suffix
  • any webidl method that returns -> Rc<Promise> needs updating Bindings.conf to remove useRcPromise from that interface
  • any #[dom_struct] or #[derive(JSTraceable)] struct containing a Rc<Promise> changes to TracedPromise (and remove any #[conditional_malloc_size_of] for that field)
  • any Rc<Promise>/&Rc<Promise> in an argument position should be &RootedPromise or &Promise, whichever is easier

Make sure to build with --use-crown to catch new cases that need extra rooting (possibly adding #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] and rooting the struct on the the stack).

Please leave a comment claiming files that you will convert. We're not going to assign one single person to this issue because it can be parallelized very effectively.

Infrastructure to convert:

Files to convert: