bug 1600111: remote: make nsIRemoteAgent.close() sync r=remote-protocol-reviewers,whimboo,maja_zf
authorAndreas Tolfsen <ato@sny.no>
Wed, 04 Dec 2019 11:57:06 +0000
changeset 505300 14e3e7d7a496f6a71c01ae224cda0bca82a76d77
parent 505299 e4a0fb55b56ba6c41e4526d222c977fec3f70da6
child 505301 13fb375eaf14bd9fae5c607aa60015d2b3bd0f2d
push id36881
push userdvarga@mozilla.com
push dateWed, 04 Dec 2019 16:22:31 +0000
treeherdermozilla-central@13fb375eaf14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, whimboo, maja_zf
bugs1600111
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1600111: remote: make nsIRemoteAgent.close() sync r=remote-protocol-reviewers,whimboo,maja_zf Interfaces exposed over XPIDL cannot be marked async, otherwise their return values get lost. This patch makes nsIRemoteAgent.close() synchronous by removing the use of async/await. Unfortunately Rust does not yet support deserialising promises sent across XPIDL, so in an effort to retain the original API internally the function now returns a promise. This means the function can be awaited in JS only, which we make use of in remote/test/browser/head.js. Differential Revision: https://phabricator.services.mozilla.com/D55172
remote/RemoteAgent.jsm
--- a/remote/RemoteAgent.jsm
+++ b/remote/RemoteAgent.jsm
@@ -91,39 +91,41 @@ class RemoteAgentClass {
         mainTarget.wsDebuggerURL
       );
     } catch (e) {
       await this.close();
       throw new Error(`Unable to start remote agent: ${e.message}`, e);
     }
   }
 
-  async close() {
+  close() {
     try {
       // if called early at startup, preferences may not be available
       try {
         Preferences.reset(Object.keys(RecommendedPreferences));
       } catch (e) {}
 
       // destroy targets before stopping server,
       // otherwise the HTTP will fail to stop
       if (this.targets) {
         this.targets.destructor();
       }
 
       if (this.listening) {
-        await this.server.stop();
+        return this.server.stop();
       }
     } catch (e) {
       // this function must never fail
       log.error("unable to stop listener", e);
     } finally {
       this.server = null;
       this.targets = null;
     }
+
+    return Promise.resolve();
   }
 
   get scheme() {
     if (!this.server) {
       return null;
     }
     return this.server.identity.primaryScheme;
   }