bug 1523104: remote: destroy the related Session when the WebSocket connection drops; r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 05 Mar 2019 12:57:04 -0800
changeset 524120 f9eb88415e06e11f3bf58ead711168f633111283
parent 524119 45eecaf3a611fd15617ed9f694b02facee912ea8
child 524121 e43dbe94d1aa420cfb48d25bb022a9578f6e7fae
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1523104
milestone67.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 1523104: remote: destroy the related Session when the WebSocket connection drops; r=ato
remote/TargetListener.jsm
--- a/remote/TargetListener.jsm
+++ b/remote/TargetListener.jsm
@@ -59,19 +59,35 @@ class TargetListener {
    *
    * @param String eventName
    * @param WebSocketDebuggerTransport transport
    * @param SocketListener listener
    */
   onConnectionAccepted(eventName, transport, listener) {
     const conn = new Connection(this.nextConnID++, transport);
     transport.ready();
+    transport.on("close", this.onConnectionClosed.bind(this, conn));
     this.sessions.set(conn, new Session(conn, this.target));
   }
 
+  /**
+   * WebSocketTransport's `close` listener. Called whenever a new WebSocket connection is
+   * closed.
+   *
+   * @param Connection conn
+   * @param String eventName
+   */
+  onConnectionClosed(conn, eventName) {
+    const session = this.sessions.get(conn);
+    if (!session) {
+      return;
+    }
+    session.destructor();
+  }
+
   get url() {
     if (this.listening) {
       const {network, host, port} = this.listener;
       return `${network}://${host}:${port}/`;
     }
     return null;
   }