Repository: tinkerpop
Updated Branches:
  refs/heads/tp33 1f15781ac -> bf07f13b5


fix(DriverRemoteConnection): return the promise on close

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f6e50ae2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f6e50ae2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f6e50ae2

Branch: refs/heads/tp33
Commit: f6e50ae231ebd6cf9e488522967ad1d483de4781
Parents: 309957b
Author: Elliott Foster <ellio...@codebrews.com>
Authored: Tue Jul 3 12:35:55 2018 -0500
Committer: GitHub <nore...@github.com>
Committed: Tue Jul 3 12:35:55 2018 -0500

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js      | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6e50ae2/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index d9e6000..0f7cedb 100644
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -190,16 +190,16 @@ class DriverRemoteConnection extends RemoteConnection {
    * @return {Promise}
    */
   close() {
-    if (this._closePromise) {
-      return this._closePromise;
-    }
-    this._closePromise = new Promise(resolve => {
-      this._ws.on('close', function () {
-        this.isOpen = false;
-        resolve();
+    if (!this._closePromise) {
+      this._closePromise = new Promise(resolve => {
+        this._ws.on('close', function () {
+          this.isOpen = false;
+          resolve();
+        });
+        this._ws.close();
       });
-      this._ws.close();
-    });
+    }
+    return this._closePromise;
   }
 }
 
@@ -226,4 +226,4 @@ const bufferFromString = (Int8Array.from !== Buffer.from && 
Buffer.from) || func
   return new Buffer(text, 'utf8');
 };
 
-module.exports = DriverRemoteConnection;
\ No newline at end of file
+module.exports = DriverRemoteConnection;

Reply via email to