Commit f2980760 authored by Luca Greco's avatar Luca Greco
Browse files

Bug 1688040 - part11: Fix dom::Promise leaked by...

Bug 1688040 - part11: Fix dom::Promise leaked by RequestWorkerRunnable::ProcessHandlerResult when handling the result of an async method call. r=baku

This patch fixes a leak that I spotted while investigating a separate shutdown leak triggered by D121683

(This one is not strictly related to D121683, but apparently none of the xpcshell tests part of this
stack of patches reported it at a shutdown leak, nevertheless it was detected as a shutdown leak
while running the test_ext_identity.html mochitest on the background service worker, after
the other leak specific to D121683 was fixed, and after investigating it using cc logs and heapgraph's
find_roots.py I confirmed that it's a shutdown leak introduced here in RequestWorkerRunnable::ProcessHandlerResult).

Differential Revision: https://phabricator.services.mozilla.com/D122968
parent b88d5ff3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -533,12 +533,12 @@ bool RequestWorkerRunnable::ProcessHandlerResult(

      ErrorResult rv;
      nsIGlobalObject* glob = xpc::CurrentNativeGlobal(aCx);
      already_AddRefed<dom::Promise> promise =
      RefPtr<dom::Promise> retPromise =
          dom::Promise::Resolve(glob, aCx, aRetval, rv);
      if (rv.Failed()) {
        return false;
      }
      promise.take()->AppendNativeHandler(mPromiseProxy);
      retPromise->AppendNativeHandler(mPromiseProxy);
      return true;
    }
  }